Skip to content

Commit 90526f3

Browse files
authored
fix(ui): stop composer mic hover shift and stray red hover (#125565)
* fix(ui): stop composer mic hover shift and stray red hover The device-picker chevron collapsed to width 0 while idle and grew to 20px on hover, shoving the right-aligned mic button 20px left under the cursor on every mouse-over. Detach the picker into its own fixed-width ghost button beside the mic instead of morphing the mic's shape into a split pill; hover only fades the picker's opacity, so the reserved layout never shifts. Also fixes the mic showing the send button's loud accent-red hover in dark/openknot themes: those themes overrode .chat-send-btn:hover directly, which outranked every variant's own hover rule (including the intentional neutral mic hover and the stop button's danger hover). Theme overrides now set a --chat-send-hover-background variable that each variant's hover rule can still take precedence over. * chore(scripts): register composer mic hover proof script Missing package.json entry made the deadcode full-tree scan flag the new capture script as an unused file, same as the existing ui:proof:workboard sibling.
1 parent 6611e40 commit 90526f3

4 files changed

Lines changed: 145 additions & 27 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,7 @@
19881988
"ui:i18n:report": "node --import tsx scripts/control-ui-i18n-report.ts",
19891989
"ui:i18n:sync": "node --import tsx scripts/control-ui-i18n.ts sync --write",
19901990
"ui:i18n:verify": "node --import tsx scripts/control-ui-i18n-verify.ts verify",
1991+
"ui:proof:composer-mic-hover": "node --import tsx scripts/capture-composer-mic-hover-proof.mts",
19911992
"ui:proof:workboard": "node --import tsx scripts/capture-workboard-ui-proof.mts",
19921993
"native:i18n:baseline": "node --import tsx scripts/native-app-i18n.ts baseline --write",
19931994
"native:i18n:check": "node --import tsx scripts/native-app-i18n.ts check",
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env node
2+
// Captures composer mic-hover proof shots: idle vs hovered talk control, plus
3+
// the mic button's x position in both states (the hover-shift regression).
4+
import { mkdir } from "node:fs/promises";
5+
import path from "node:path";
6+
import { chromium } from "playwright";
7+
import {
8+
canRunPlaywrightChromium,
9+
installMockGateway,
10+
resolvePlaywrightChromiumExecutablePath,
11+
startControlUiE2eServer,
12+
} from "../ui/src/test-helpers/control-ui-e2e.ts";
13+
14+
function readOption(name: string): string | undefined {
15+
const prefix = `--${name}=`;
16+
const inline = process.argv.slice(2).find((arg) => arg.startsWith(prefix));
17+
if (inline) {
18+
return inline.slice(prefix.length);
19+
}
20+
const index = process.argv.indexOf(`--${name}`);
21+
return index >= 0 ? process.argv[index + 1] : undefined;
22+
}
23+
24+
const outputDir = path.resolve(
25+
readOption("output-dir") ?? ".artifacts/control-ui-e2e/composer-mic-hover-proof",
26+
);
27+
const label = readOption("label") ?? "after";
28+
const executablePath = resolvePlaywrightChromiumExecutablePath(chromium.executablePath());
29+
if (!canRunPlaywrightChromium(executablePath)) {
30+
throw new Error(`Playwright Chromium is unavailable at ${executablePath}`);
31+
}
32+
33+
await mkdir(outputDir, { recursive: true });
34+
const server = await startControlUiE2eServer(undefined, { source: true });
35+
const browser = await chromium.launch({ executablePath });
36+
const context = await browser.newContext({
37+
colorScheme: "dark",
38+
viewport: { width: 1280, height: 800 },
39+
});
40+
const page = await context.newPage();
41+
page.setDefaultTimeout(30_000);
42+
43+
try {
44+
await installMockGateway(page);
45+
await page.goto(`${server.baseUrl}chat`);
46+
const composer = page.locator(".agent-chat__input");
47+
await composer.waitFor({ state: "visible" });
48+
const voice = page.getByRole("button", { name: "Start voice input" });
49+
await voice.waitFor({ state: "visible" });
50+
51+
await page.mouse.move(10, 10);
52+
await page.waitForTimeout(400);
53+
const composerBox = await composer.boundingBox();
54+
if (!composerBox) {
55+
throw new Error("composer has no layout box");
56+
}
57+
const clip = {
58+
x: Math.max(0, composerBox.x - 12),
59+
y: Math.max(0, composerBox.y - 12),
60+
width: Math.min(1280, composerBox.width + 24),
61+
height: composerBox.height + 24,
62+
};
63+
const idleVoiceBox = await voice.boundingBox();
64+
await page.screenshot({ clip, path: path.join(outputDir, `${label}-idle.png`) });
65+
66+
await voice.hover();
67+
await page.waitForTimeout(400);
68+
const hoverVoiceBox = await voice.boundingBox();
69+
await page.screenshot({ clip, path: path.join(outputDir, `${label}-hover.png`) });
70+
71+
const picker = page.getByRole("button", { name: "Microphone input" });
72+
if (await picker.count()) {
73+
await picker.hover();
74+
await page.waitForTimeout(400);
75+
await page.screenshot({ clip, path: path.join(outputDir, `${label}-hover-chevron.png`) });
76+
await picker.click();
77+
await page.waitForTimeout(500);
78+
await page.screenshot({
79+
path: path.join(outputDir, `${label}-picker-open.png`),
80+
clip: { ...clip, y: Math.max(0, clip.y - 260), height: clip.height + 260 },
81+
});
82+
await page.keyboard.press("Escape");
83+
}
84+
85+
if (!idleVoiceBox || !hoverVoiceBox) {
86+
throw new Error("voice button has no layout box");
87+
}
88+
console.log(
89+
JSON.stringify(
90+
{
91+
label,
92+
idleVoiceX: idleVoiceBox.x,
93+
hoverVoiceX: hoverVoiceBox.x,
94+
hoverShiftPx: hoverVoiceBox.x - idleVoiceBox.x,
95+
outputDir,
96+
},
97+
null,
98+
2,
99+
),
100+
);
101+
} finally {
102+
await context.close();
103+
await browser.close();
104+
await server.close();
105+
}

‎ui/src/e2e/chat-composer-redesign.e2e.test.ts‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ suite.define(() => {
517517
await expect.poll(() => camera.count()).toBe(0);
518518
expect(await page.evaluate(() => matchMedia("(pointer: coarse)").matches)).toBe(false);
519519
await expect
520-
.poll(() => microphonePickerShell.evaluate((node) => node.getBoundingClientRect().width))
521-
.toBe(0);
520+
.poll(() => microphonePickerShell.evaluate((node) => getComputedStyle(node).opacity))
521+
.toBe("0");
522522
// Resize re-layout is async; wait for the header controls to adopt the
523523
// mobile width before sampling one-shot bounding boxes below.
524524
await expect
@@ -611,18 +611,31 @@ suite.define(() => {
611611
await expect.poll(() => voice.isDisabled()).toBe(true);
612612
await page.mouse.move(0, 0);
613613
await expect.poll(() => page.locator("wa-tooltip[open]").count()).toBe(0);
614+
// The picker reserves its width while hidden; only opacity reveals it, so
615+
// hovering never shifts the right-aligned mic/send cluster sideways.
614616
await expect
615617
.poll(() => microphonePickerShell.evaluate((node) => node.getBoundingClientRect().width))
616-
.toBe(0);
618+
.toBe(22);
619+
await expect
620+
.poll(() => microphonePickerShell.evaluate((node) => getComputedStyle(node).opacity))
621+
.toBe("0");
617622
await expect.poll(() => voice.evaluate((node) => getComputedStyle(node).opacity)).toBe("0.4");
623+
const idleVoiceBox = await voice.boundingBox();
624+
expect(idleVoiceBox).not.toBeNull();
618625

619626
await voice.hover();
620-
await expect
621-
.poll(() => microphonePickerShell.evaluate((node) => node.getBoundingClientRect().width))
622-
.toBe(20);
623627
await expect
624628
.poll(() => microphonePickerShell.evaluate((node) => getComputedStyle(node).opacity))
625629
.toBe("1");
630+
await expect
631+
.poll(() => microphonePickerShell.evaluate((node) => node.getBoundingClientRect().width))
632+
.toBe(22);
633+
const hoveredVoiceBox = await voice.boundingBox();
634+
expect(hoveredVoiceBox).not.toBeNull();
635+
if (!idleVoiceBox || !hoveredVoiceBox) {
636+
throw new Error("expected voice button layout boxes around hover");
637+
}
638+
expect(hoveredVoiceBox.x).toBe(idleVoiceBox.x);
626639
await microphonePicker.click();
627640
await expect.poll(() => microphonePicker.getAttribute("aria-expanded")).toBe("true");
628641
await expect.poll(() => page.locator(".chat-talk-input-picker[open]").count()).toBe(1);

‎ui/src/styles/chat/layout.css‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,17 +3503,21 @@ button.chat-pr__diff {
35033503
stroke-linejoin: round;
35043504
}
35053505

3506+
/* Theme overrides adjust the hover fill via this variable instead of their own
3507+
:hover rules: a :root[data-theme] selector outranks every variant's hover
3508+
(--voice, --stop), which painted the idle mic with the send button's loud
3509+
accent hover in dark themes. */
35063510
.chat-send-btn:hover:not(:disabled) {
3507-
background: var(--accent-hover);
3511+
background: var(--chat-send-hover-background, var(--accent-hover));
35083512
box-shadow: 0 2px 12px var(--accent-glow);
35093513
}
35103514

3511-
:root[data-theme="dark"] .chat-send-btn:hover:not(:disabled) {
3512-
background: var(--primary-hover);
3515+
:root[data-theme="dark"] .chat-send-btn {
3516+
--chat-send-hover-background: var(--primary-hover);
35133517
}
35143518

3515-
:root[data-theme="openknot"] .chat-send-btn:hover:not(:disabled) {
3516-
background: var(--primary-hover);
3519+
:root[data-theme="openknot"] .chat-send-btn {
3520+
--chat-send-hover-background: var(--primary-hover);
35173521
}
35183522

35193523
/* Outline (not box-shadow) so the hover rules' higher-specificity box-shadow
@@ -3561,11 +3565,11 @@ button.chat-pr__diff {
35613565
--chat-voice-hover-color: var(--text);
35623566
display: inline-flex;
35633567
align-items: center;
3568+
gap: 4px;
35643569
flex: 0 0 auto;
35653570
}
35663571

35673572
.chat-talk-control--active {
3568-
--chat-picker-border: color-mix(in srgb, var(--accent) 24%, transparent);
35693573
--chat-picker-background: color-mix(in srgb, var(--accent) 14%, transparent);
35703574
--chat-picker-color: var(--accent);
35713575
--chat-picker-hover-background: color-mix(in srgb, var(--accent) 20%, transparent);
@@ -3576,24 +3580,20 @@ button.chat-pr__diff {
35763580
display: inline-flex;
35773581
}
35783582

3579-
.chat-talk-control .chat-send-btn {
3580-
border-radius: var(--radius-full) 0 0 var(--radius-full);
3581-
}
3582-
3583+
/* The device picker is a detached round ghost button beside the mic — the mic
3584+
itself never changes shape. It reserves its width at all times and hover
3585+
only fades it in; collapsing the width instead shifts the whole
3586+
right-aligned mic/send cluster sideways under the cursor on mouse-over. */
35833587
.chat-talk-input-picker {
35843588
display: inline-flex;
3585-
align-self: stretch;
3586-
width: 20px;
3587-
transition:
3588-
width 120ms ease,
3589-
opacity 100ms ease;
3589+
align-self: center;
3590+
width: 22px;
3591+
transition: opacity var(--duration-fast) ease;
35903592
}
35913593

35923594
@media (hover: hover) and (pointer: fine) {
35933595
.chat-talk-control:not(.chat-talk-control--active, :hover, :focus-within)
35943596
.chat-talk-input-picker:not([open]) {
3595-
width: 0;
3596-
min-width: 0;
35973597
opacity: 0;
35983598
}
35993599
}
@@ -3602,12 +3602,11 @@ button.chat-pr__diff {
36023602
display: inline-flex;
36033603
align-items: center;
36043604
justify-content: center;
3605-
min-width: 20px;
3606-
height: 100%;
3605+
width: 22px;
3606+
height: 22px;
36073607
padding: 0;
36083608
border: 0;
3609-
border-left: 1px solid var(--chat-picker-border, var(--border));
3610-
border-radius: 0 var(--radius-full) var(--radius-full) 0;
3609+
border-radius: var(--radius-full);
36113610
background: var(--chat-picker-background, transparent);
36123611
color: var(--chat-picker-color, var(--muted));
36133612
transition: background var(--duration-fast) ease;

0 commit comments

Comments
 (0)