Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): restore symmetry of the settings gear (#6298)
chengyongru743d40bbba04
diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsxindex 9e559966e..ffa30e12f 100644--- a/webui/browser/fixture.tsx+++ b/webui/browser/fixture.tsx@@ -13,6 +13,8 @@ import { fetchWebuiThread } from "@/lib/api";import { projectThreadEvents } from "@/lib/thread-event-projection";import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "@/components/ui/dialog";import { TooltipProvider } from "@/components/ui/tooltip";+import { Button } from "@/components/ui/button";+import { SettingsIcon } from "@/components/icons/product-icons";import { initializeI18n } from "@/i18n";import type { McpPresetInfo, UIMessage } from "@/lib/types";import "../src/globals.css";@@ -140,6 +142,8 @@ createRoot(document.getElementById("root")!).render(<TooltipProvider>? <ClientProvider client={railClient} token="fixture"><AppsFixture /></ClientProvider>: parameters.get("case") === "rail"? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><RailFixture /></ClientProvider>+ : parameters.get("case") === "settings-icon"+ ? <Button variant="icon" size="icon" aria-label="Settings"><SettingsIcon className="h-4 w-4" /></Button>: parameters.get("case") === "history"? <HistoryFixture />: <TallDialogFixture placement={parameters.get("placement") === "bottom" ? "bottom" : "center"} />}diff --git a/webui/browser/product-icons.spec.ts b/webui/browser/product-icons.spec.tsnew file mode 100644index 000000000..ff9aaf963--- /dev/null+++ b/webui/browser/product-icons.spec.ts@@ -0,0 +1,56 @@+import { expect, test } from "@playwright/test";++test("settings gear outline is symmetric about its circular hub", async ({ page }) => {+ await page.goto("/browser/fixture.html?case=settings-icon");+ const icon = page.getByRole("button", { name: "Settings", exact: true }).locator("svg");+ const error = await icon.evaluate((element) => {+ const outline = element.querySelector("path")!;+ const hub = element.querySelector("circle")!;+ const length = outline.getTotalLength();+ let maximum = 0;+ for (let index = 0; index < 64; index++) {+ const distance = length * index / 128;+ const point = outline.getPointAtLength(distance);+ const opposite = outline.getPointAtLength(distance + length / 2);+ maximum = Math.max(maximum, Math.hypot(+ point.x + opposite.x - 2 * hub.cx.baseVal.value,+ point.y + opposite.y - 2 * hub.cy.baseVal.value,+ ));+ }+ return maximum;+ });+ expect(error).toBeLessThan(0.001);+});++test("settings hover rotates the outline without transforming the hub", async ({ page }) => {+ await page.emulateMedia({ reducedMotion: "no-preference" });+ await page.goto("/browser/fixture.html?case=settings-icon");+ const button = page.getByRole("button", { name: "Settings", exact: true });+ const icon = button.locator("svg");+ for (const hovered of [true, false]) {+ const sample = icon.evaluate((element) => new Promise<{ hubChange: number; rotatingFrames: number }>((resolve) => {+ const hub = element.querySelector("circle")!;+ const outline = element.querySelector("path")!;+ const initial = hub.getScreenCTM()!;+ const started = performance.now();+ let hubChange = 0;+ let rotatingFrames = 0;+ function read() {+ const matrix = hub.getScreenCTM()!;+ for (const key of ["a", "b", "c", "d", "e", "f"] as const) {+ hubChange = Math.max(hubChange, Math.abs(matrix[key] - initial[key]));+ }+ const rotation = outline.getScreenCTM()!;+ if (rotation.a > 0.01 && rotation.b > 0.01) rotatingFrames++;+ if (performance.now() - started < 450) requestAnimationFrame(read);+ else resolve({ hubChange, rotatingFrames });+ }+ read();+ }));+ if (hovered) await button.hover();+ else await page.mouse.move(0, 0);+ const result = await sample;+ expect(result.rotatingFrames).toBeGreaterThan(0);+ expect(result.hubChange).toBeLessThan(0.0001);+ }+});diff --git a/webui/src/components/icons/product-icons.tsx b/webui/src/components/icons/product-icons.tsxindex dd6bcdd33..0ec1949f6 100644--- a/webui/src/components/icons/product-icons.tsx+++ b/webui/src/components/icons/product-icons.tsx@@ -24,7 +24,7 @@ export const SkillsIcon = productIcon("skills", <><path d="M5 18V6a3 3 0 0 1 3-3export const AutomationsIcon = productIcon("automations", <><rect x="3" y="5" width="18" height="16" rx="3" /><path d="M7 3v4m10-4v4M3 10h18m-8 2-4 4h4l-2 4 5-5h-4l1-3Z" /></>);export const ChannelsIcon = productIcon("channels", <><path d="M4 4h9a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H8l-4 3V6a2 2 0 0 1 0-2Z" /><path d="M15 8h3a3 3 0 0 1 3 3v6a2 2 0 0 1-2 2h-3l-3 2v-4" /><path d="M7 8h5" /></>);export const ArchiveIcon = productIcon("archive", <><rect x="3" y="3.5" width="18" height="4.5" rx="1.5" /><path d="M4.5 8v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V8M9 12h6" /></>);-export const SettingsIcon = productIcon("settings", <><path d="M10 3h4l.6 2.4 2.1 1.2 2.4-.7 2 3.5-1.8 1.7v2.4l1.8 1.7-2 3.5-2.4-.7-2.1 1.2L14 21h-4l-.6-2.4-2.1-1.2-2.4.7-2-3.5 1.8-1.7v-2.4L2.9 9.4l2-3.5 2.4.7 2.1-1.2L10 3Z" /><circle cx="12" cy="12" r="3" /></>);+export const SettingsIcon = productIcon("settings", <><path d="M10 3h4l.6 2.4 2.1 1.2 2.4-.7 2 3.5-1.8 1.7v1.8l1.8 1.7-2 3.5-2.4-.7-2.1 1.2L14 21h-4l-.6-2.4-2.1-1.2-2.4.7-2-3.5 1.8-1.7v-1.8L2.9 9.4l2-3.5 2.4.7 2.1-1.2L10 3Z" /><circle cx="12" cy="12" r="3" /></>);export const OverviewIcon = productIcon("overview", <><rect x="3" y="3" width="18" height="18" rx="3" /><path d="M3 9h18M9 9v12m4-4v-3m4 3v-5" /><path d="M6 6h.01" /></>);export const AppearanceIcon = productIcon("appearance", <><path d="M12 3a9 9 0 0 0 0 18h1a2 2 0 0 0 1.3-3.5 1.7 1.7 0 0 1 1.2-3H18a3 3 0 0 0 3-3A9 9 0 0 0 12 3Z" /><circle cx="7.5" cy="10" r=".8" /><circle cx="11" cy="6.8" r=".8" /><circle cx="16" cy="8" r=".8" /></>);export const ModelsIcon = productIcon("models", <><path d="m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5" /></>);diff --git a/webui/src/globals.css b/webui/src/globals.cssindex 321aab481..570c6f9d9 100644--- a/webui/src/globals.css+++ b/webui/src/globals.css@@ -1487,11 +1487,13 @@transform-origin: center;}@media (hover: hover) and (prefers-reduced-motion: no-preference) {- .icon-action [data-product-icon="settings"] {+ .icon-action [data-product-icon="settings"] > path {+ transform-box: view-box;+ transform-origin: center;transform: rotate(0deg);transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);}- .icon-action:not(:disabled):hover [data-product-icon="settings"] {+ .icon-action:not(:disabled):hover [data-product-icon="settings"] > path {transform: rotate(90deg);}}