fix(webui): round Codex speed controls to match the reasoning slider (#6703)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-18 16:44:27 +08:00
1 parent 74d070f699
commit 7e04670461
2 files changed
+26 -10

No files matched your search

+19 -3
View File
@@ -1,4 +1,15 @@
import { expect, test } from "@playwright/test";
import { expect, test, type Locator } from "@playwright/test";
async function expectSpeedCircle(button: Locator, track: { y: number; height: number }) {
const face = button.locator(":scope > [aria-hidden]");
await expect(face).toHaveCSS("corner-shape", /^(round|superellipse\(1\))$/);
const { y, width, height } = (await face.boundingBox())!;
expect(height).toBe(track.height);
expect(width).toBe(height);
expect(y).toBeCloseTo(track.y, 0);
expect(await face.evaluate((element) => Number.parseFloat(getComputedStyle(element).borderTopLeftRadius))).toBeGreaterThanOrEqual(height / 2);
await expect(button).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
}
for (const width of [390, 1280]) {
test(`current-chat model options preserve the compact preset menu at ${width}px`, async ({ page }, testInfo) => {
@@ -29,6 +40,7 @@ for (const width of [390, 1280]) {
const thumb = (await dialog.locator(".reasoning-effort-thumb").boundingBox())!;
expect(track.height).toBe(20);
expect(thumb.height).toBe(24);
await expectSpeedCircle(fast, track);
const stops = await dialog.locator(".reasoning-effort-tick").evaluateAll((elements) =>
elements.map((element) => element.getBoundingClientRect().x),
);
@@ -84,9 +96,9 @@ test("Temporary Chats do not expose model option controls", async ({ page }) =>
await expect(page.getByRole("button", { name: "Fast", exact: true })).toHaveCount(0);
});
test("reselecting medium and choosing Ultrafast sends and remembers both concrete values", async ({ page }) => {
test("reselecting medium and choosing Ultrafast sends and remembers both concrete values", async ({ page }, testInfo) => {
await page.setViewportSize({ width: 320, height: 800 });
await page.goto("/browser/fixture.html?case=model-options&ultrafast");
await page.goto("/browser/fixture.html?case=model-options&ultrafast&dark");
const open = page.getByRole("button", { name: "Default", exact: true });
await open.click();
const dialog = page.getByRole("dialog", { name: "Switch model", exact: true });
@@ -134,9 +146,13 @@ test("reselecting medium and choosing Ultrafast sends and remembers both concret
await ultrafast.click();
await expect(ultrafast).toHaveAttribute("aria-pressed", "true");
await expect(fast).toHaveAttribute("aria-pressed", "false");
const track = (await dialog.locator(".reasoning-effort-track").boundingBox())!;
await expectSpeedCircle(fast, track);
await expectSpeedCircle(ultrafast, track);
expect(await speeds.evaluate((group) => [...group.querySelectorAll("button")].every((button) =>
button.scrollWidth <= button.clientWidth + 1 && button.offsetWidth >= 44 && button.offsetHeight >= 44,
))).toBe(true);
await dialog.locator(".model-options-row").screenshot({ path: testInfo.outputPath("model-options-ultrafast-320.png") });
await dialog.press("Escape");
await page.getByLabel("Message input").fill("Test this speed");
await page.getByRole("button", { name: "Send message", exact: true }).click();
@@ -29,19 +29,19 @@ export function CodexSpeedControl({ value, onChange, ultrafastSupported }: {
size="sm"
aria-label={label}
aria-pressed={selected}
className="group/speed h-8 w-8 rounded-lg p-0 max-sm:h-11 max-sm:w-11"
className="group/speed size-8 rounded-full p-0 hover:bg-transparent active:bg-transparent aria-pressed:bg-transparent max-sm:size-11"
onClick={() => onChange(selected ? false : mode)}
>
<span aria-hidden className={cn(
"grid size-7 place-items-center rounded-md",
selected ? "bg-foreground text-background" : "bg-muted/65 text-muted-foreground group-hover/speed:text-foreground",
"grid size-[20px] place-items-center rounded-full",
selected ? "bg-foreground text-background" : "bg-foreground/[0.07] text-muted-foreground group-hover/speed:bg-foreground/[0.12] group-hover/speed:text-foreground",
)}>
{ultra ? (
<span className="relative size-[18px]">
<Zap className="absolute left-0 top-0 size-3.5 opacity-60" />
<Zap className="absolute bottom-0 right-0 size-3.5" />
<span className="relative size-4">
<Zap className="absolute left-0 top-0 size-3 opacity-60" />
<Zap className="absolute bottom-0 right-0 size-3" />
</span>
) : <Zap className="size-4" />}
) : <Zap className="size-3.5" />}
</span>
</Button>
</HoverHint>