Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): center the settings gear glyph in its viewBox (BUG-79)
Ma5eb749b067c
diff --git a/desktop-app/ui/src/components/SidebarNav/__tests__/iconSettingsCentering.test.tsx b/desktop-app/ui/src/components/SidebarNav/__tests__/iconSettingsCentering.test.tsxnew file mode 100644index 000000000..f761c08b7--- /dev/null+++ b/desktop-app/ui/src/components/SidebarNav/__tests__/iconSettingsCentering.test.tsx@@ -0,0 +1,133 @@+// @vitest-environment jsdom+/**+ * BUG-79 — the settings gear must be centered in its 24×24 viewBox, because+ * every housing (sidebar nav icon, menu item icon, settings card tile)+ * grid-centers the svg box and inherits whatever bias the glyph itself+ * carries. Screenshot-free proof: recompute the arc-exact ink bounding box of+ * the rendered path data (endpoints plus the extreme points that actually lie+ * on each arc's sweep), apply the rendered <g> transform, and require the box+ * to be centered on (12, 12).+ */+import { afterEach, describe, expect, it } from 'vitest'+import { cleanup, render } from '@testing-library/react'+import { IconSettings } from '../icons'++afterEach(() => cleanup())++interface ArcPoint {+ x1: number+ y1: number+ rx: number+ ry: number+ laf: number+ sf: number+ x2: number+ y2: number+}++/** Absolute M/h/v/l coordinates plus arc extremes, W3C F.6 endpoint→center. */+function pathInkPoints(d: string): Array<[number, number]> {+ const tokens = d.match(/[MmhHlLvVaAzZ]|-?\d*\.?\d+/g) ?? []+ const points: Array<[number, number]> = []+ let x = 0+ let y = 0+ let command: string | null = null+ for (let index = 0; index < tokens.length; index += 1) {+ const token = tokens[index]!+ if (/[a-zA-Z]/.test(token)) {+ command = token+ if (command === 'M') command = 'L'+ continue+ }+ const value = parseFloat(token)+ if (command === 'M' || command === 'L') {+ x = value+ y = parseFloat(tokens[index + 1]!)+ index += 1+ points.push([x, y])+ } else if (command === 'h') {+ x += value+ points.push([x, y])+ } else if (command === 'v') {+ y += value+ points.push([x, y])+ } else if (command === 'l') {+ x += value+ y += parseFloat(tokens[index + 1]!)+ index += 1+ points.push([x, y])+ } else if (command === 'a') {+ const arc: ArcPoint = {+ x1: x,+ y1: y,+ rx: value,+ ry: parseFloat(tokens[index + 1]!),+ laf: parseFloat(tokens[index + 3]!),+ sf: parseFloat(tokens[index + 4]!),+ x2: x + parseFloat(tokens[index + 5]!),+ y2: y + parseFloat(tokens[index + 6]!),+ }+ index += 6+ points.push([arc.x2, arc.y2])+ const x1p = (arc.x1 - arc.x2) / 2+ const y1p = (arc.y1 - arc.y2) / 2+ const denominator = arc.rx * arc.rx * y1p * y1p + arc.ry * arc.ry * x1p * x1p+ if (denominator === 0) continue+ const numerator = arc.rx * arc.rx * arc.ry * arc.ry - denominator+ let coefficient = Math.sqrt(Math.max(0, numerator / denominator))+ if (arc.laf === arc.sf) coefficient = -coefficient+ const cx = (coefficient * arc.rx * y1p) / arc.ry + (arc.x1 + arc.x2) / 2+ const cy = (-coefficient * arc.ry * x1p) / arc.rx + (arc.y1 + arc.y2) / 2+ if (Math.abs(Math.hypot(arc.x1 - cx, arc.y1 - cy) - arc.rx) > 0.05) continue+ const startAngle = Math.atan2(arc.y1 - cy, arc.x1 - cx)+ const endAngle = Math.atan2(arc.y2 - cy, arc.x2 - cx)+ let sweep = endAngle - startAngle+ if (arc.sf === 1 && sweep < 0) sweep += 2 * Math.PI+ if (arc.sf === 0 && sweep > 0) sweep -= 2 * Math.PI+ for (const axis of [0, Math.PI / 2, Math.PI, -Math.PI / 2]) {+ let delta = axis - startAngle+ if (arc.sf === 1 && delta < 0) delta += 2 * Math.PI+ if (arc.sf === 0 && delta > 0) delta -= 2 * Math.PI+ const onArc = arc.sf === 1 ? delta <= sweep + 0.01 : delta >= sweep - 0.01+ if (onArc) points.push([cx + arc.rx * Math.cos(axis), cy + arc.ry * Math.sin(axis)])+ }+ x = arc.x2+ y = arc.y2+ }+ }+ return points+}++function parseTranslate(transform: string | null): [number, number] {+ if (!transform) return [0, 0]+ const match = transform.match(/translate\(\s*(-?[\d.]+)[\s,]+(-?[\d.]+)?\s*\)/)+ if (!match) return [0, 0]+ return [parseFloat(match[1]!), match[2] === undefined ? 0 : parseFloat(match[2])]+}++describe('IconSettings centering (BUG-79)', () => {+ it('keeps the gear glyph ink box centered in the 24×24 viewBox', () => {+ const { container } = render(<IconSettings />)+ const svg = container.querySelector('svg')+ const group = svg?.querySelector('g')+ const path = svg?.querySelector('path')+ expect(svg?.getAttribute('viewBox')).toBe('0 0 24 24')+ expect(path?.getAttribute('d')).toBeTruthy()++ const [dx, dy] = parseTranslate(group?.getAttribute('transform') ?? null)+ const points = pathInkPoints(path!.getAttribute('d')!).map(+ ([x, y]) => [x + dx, y + dy] as [number, number]+ )+ const xs = points.map(point => point[0])+ const ys = points.map(point => point[1])+ const centerX = (Math.min(...xs) + Math.max(...xs)) / 2+ const centerY = (Math.min(...ys) + Math.max(...ys)) / 2++ // The hub circle shares the group translate, so the whole glyph moves as+ // one; the corrected box must sit within 0.005 units of the viewBox center.+ expect(centerX).toBeGreaterThanOrEqual(12 - 0.005)+ expect(centerX).toBeLessThanOrEqual(12 + 0.005)+ expect(centerY).toBeGreaterThanOrEqual(12 - 0.005)+ expect(centerY).toBeLessThanOrEqual(12 + 0.005)+ })+})diff --git a/desktop-app/ui/src/components/SidebarNav/icons.tsx b/desktop-app/ui/src/components/SidebarNav/icons.tsxindex e199afcd0..627040068 100644--- a/desktop-app/ui/src/components/SidebarNav/icons.tsx+++ b/desktop-app/ui/src/components/SidebarNav/icons.tsx@@ -253,8 +253,14 @@ export function IconVolumeOff(props: IconProps) {export function IconSettings(props: IconProps) {return (<svg viewBox="0 0 24 24" aria-hidden="true" {...BASE_STROKE_PROPS} {...props}>- <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.51a2 2 0 0 1 1-1.72l.15-.1a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2Z" />- <circle cx="12" cy="12" r="3" />+ {/* BUG-79 — the gear path's ink box is biased high in the 24×24 viewBox+ (top margin 2.00, bottom 2.18, so the bbox center sits at y 11.91).+ The translate re-centers the whole glyph — path and hub together — so+ it sits centered in every housing that grid-centers this svg. */}+ <g transform="translate(0 0.09)">+ <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.51a2 2 0 0 1 1-1.72l.15-.1a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2Z" />+ <circle cx="12" cy="12" r="3" />+ </g></svg>)}