Skip to content

Commit 3d08dfd

Browse files
committed
fix(ui): carry --primary-hover through the accent override
The accent apply path set --primary but not --primary-hover, so dark Claw/Knot primary buttons reverted to the theme hover color while an accent was active (ClawSweeper P2). Derive it from --primary like the accent hover, clear it on reset, and prove the resolved hover color via a painted probe in the appearance e2e.
1 parent cbf1d70 commit 3d08dfd

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎ui/src/app/control-ui-presentation.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ describe("Control UI accent presentation", () => {
2121
applyControlUiAccent("#fbbf24");
2222
expect(style.getPropertyValue("--accent")).toBe("#fbbf24");
2323
expect(style.getPropertyValue("--primary")).toBe("#fbbf24");
24+
// Hover must ride the accent too; dark Claw/Knot primary buttons read it.
25+
expect(style.getPropertyValue("--primary-hover")).toBe(
26+
"color-mix(in srgb, var(--primary) 82%, white 18%)",
27+
);
2428
expect(style.getPropertyValue("--accent-foreground")).toBe("#000000");
2529
expect(style.getPropertyValue("--primary-foreground")).toBe("#000000");
2630

@@ -29,7 +33,12 @@ describe("Control UI accent presentation", () => {
2933
expect(style.getPropertyValue("--primary-foreground")).toBe("#ffffff");
3034

3135
applyControlUiPresentation({ environment: null });
32-
for (const property of ["--accent", "--accent-foreground", "--primary-foreground"]) {
36+
for (const property of [
37+
"--accent",
38+
"--accent-foreground",
39+
"--primary-hover",
40+
"--primary-foreground",
41+
]) {
3342
expect(style.getPropertyValue(property)).toBe("");
3443
}
3544
});

‎ui/src/app/control-ui-presentation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const ACCENT_CSS_VARIABLES = [
77
"--accent-subtle",
88
"--accent-glow",
99
"--primary",
10+
"--primary-hover",
1011
"--primary-foreground",
1112
"--focus",
1213
"--focus-ring",
@@ -46,6 +47,7 @@ export function applyControlUiAccent(userAccent?: string): void {
4647
root.style.setProperty(property, ink);
4748
}
4849
root.style.setProperty("--accent-hover", "color-mix(in srgb, var(--accent) 82%, white 18%)");
50+
root.style.setProperty("--primary-hover", "color-mix(in srgb, var(--primary) 82%, white 18%)");
4951
root.style.setProperty("--accent-subtle", mix("--accent", 16));
5052
root.style.setProperty("--accent-glow", mix("--accent", 30));
5153
root.style.setProperty("--focus", mix("--ring", 22));

‎ui/src/e2e/appearance-settings-defaults.e2e.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,23 @@ async function readAccentPresentation(page: Page) {
126126
});
127127
}
128128

129+
/** Resolves --primary-hover to concrete channels via a painted probe; computed
130+
* custom-property reads return the raw color-mix() expression, not a color. */
131+
async function readResolvedPrimaryHover(page: Page): Promise<number[]> {
132+
return page.evaluate(() => {
133+
const probe = document.createElement("div");
134+
probe.style.backgroundColor = "var(--primary-hover)";
135+
document.body.append(probe);
136+
const value = getComputedStyle(probe).backgroundColor;
137+
probe.remove();
138+
// Chromium serializes mixed colors as color(srgb r g b) with 0-1 floats.
139+
const channels = (value.match(/\d+(?:\.\d+)?/g) ?? []).slice(0, 3).map(Number);
140+
return channels.every((channel) => channel <= 1)
141+
? channels.map((channel) => channel * 255)
142+
: channels;
143+
});
144+
}
145+
129146
async function readThemeImportRaceState(page: Page) {
130147
const importer = page.locator(".settings-theme-import");
131148
const message = importer.locator(".settings-theme-import__message");
@@ -451,6 +468,16 @@ suite.define(() => {
451468
primaryForeground: "#000000",
452469
});
453470
await expect.poll(() => readPersistedSettings(page)).toMatchObject({ accent: mintAccent });
471+
// Dark Knot primary buttons hover on --primary-hover; it must track the
472+
// selected accent (mint mixed 18% toward white), not the theme default.
473+
const hoverChannels = await readResolvedPrimaryHover(page);
474+
const expectedHover = [0x52, 0xc9, 0x9a].map((channel) =>
475+
Math.round(channel * 0.82 + 255 * 0.18),
476+
);
477+
expect(hoverChannels).toHaveLength(3);
478+
for (const [index, channel] of hoverChannels.entries()) {
479+
expect(Math.abs(channel - expectedHover[index]!)).toBeLessThanOrEqual(2);
480+
}
454481
await captureViewport(page, "09-accent-mint-selected.png");
455482

456483
await gateway.setMethodResponse(

0 commit comments

Comments
 (0)