fix(webui): theme the custom reasoning effort picker (#6730)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-20 13:02:44 +08:00
1 parent 51fa1a7f74
commit 7935176eb7
3 files changed
+55 -24

No files matched your search

+36 -14
View File
@@ -251,20 +251,42 @@ test("keeps the reasoning slider track visible while a Codex preset awaits its e
await expect(effort).toHaveAttribute("aria-valuetext", "high"); await expect(effort).toHaveAttribute("aria-valuetext", "high");
}); });
test("keeps the custom reasoning effort as a concrete value for a self-hosted preset", async ({ page }) => { for (const { width, height, theme } of [
await page.goto("/browser/fixture.html?case=model-options&group=local"); { width: 1280, height: 900, theme: "light" },
await page.getByRole("button", { name: "Default", exact: true }).click(); { width: 390, height: 440, theme: "dark" },
const dialog = page.getByRole("dialog", { name: "Switch model", exact: true }); ]) {
await dialog.getByRole("option", { name: "Custom API", exact: true }).click(); test(`selects a custom preset's reasoning effort in the themed picker at ${width}px`, async ({ page }, testInfo) => {
await page.getByRole("button", { name: "Custom API", exact: true }).click(); await page.setViewportSize({ width, height });
const effort = dialog.getByRole("combobox", { name: "Reasoning effort" }); await page.goto(`/browser/fixture.html?case=model-options&group=local&${theme}`);
await expect(effort.locator("option:checked")).toHaveText("extended"); await page.getByRole("button", { name: "Default", exact: true }).click();
await effort.selectOption({ label: "low" }); const dialog = page.getByRole("dialog", { name: "Switch model", exact: true });
await dialog.press("Escape"); await dialog.getByRole("option", { name: "Custom API", exact: true }).click();
await page.getByLabel("Message input").fill("Review custom API reasoning options"); await page.getByRole("button", { name: "Custom API", exact: true }).click();
await page.getByRole("button", { name: "Send message", exact: true }).click(); const effort = dialog.getByRole("combobox", { name: "Reasoning effort" });
await expect(page.getByLabel("Sent model options")).toHaveText("Reasoning: low; Codex Fast: unchanged"); await expect(effort).toHaveText("extended");
}); await dialog.evaluate((element) => Promise.all(element.getAnimations().map((animation) => animation.finished)));
await effort.press("Enter");
const list = page.getByRole("listbox").filter({ has: page.getByRole("option", { name: "extended", exact: true }) });
const current = list.getByRole("option", { name: "extended", exact: true });
const low = list.getByRole("option", { name: "low", exact: true });
await expect(current).toBeFocused();
await expect(current).toHaveAttribute("aria-selected", "true");
await expect(low).toBeInViewport({ ratio: 1 });
await page.screenshot({ path: testInfo.outputPath(`custom-reasoning-effort-${theme}.png`) });
await current.press("Home");
await expect(low).toBeFocused();
await low.press("Escape");
await expect(list).toBeHidden();
await expect(effort).toBeFocused();
await effort.click();
await low.click();
await expect(effort).toHaveText("low");
await effort.press("Escape");
await page.getByLabel("Message input").fill("Review custom API reasoning options");
await page.getByRole("button", { name: "Send message", exact: true }).click();
await expect(page.getByLabel("Sent model options")).toHaveText("Reasoning: low; Codex Fast: unchanged");
});
}
test("touch drag previews the next effort without saving it until release", async ({ page }) => { test("touch drag previews the next effort without saving it until release", async ({ page }) => {
await page.setViewportSize({ width: 320, height: 800 }); await page.setViewportSize({ width: 320, height: 800 });
@@ -2,6 +2,7 @@ import { useRef, useState, type CSSProperties, type PointerEvent } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { CodexSpeedControl } from "@/components/ui/codex-speed-control"; import { CodexSpeedControl } from "@/components/ui/codex-speed-control";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip-primitives"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip-primitives";
import type { ModelOptionsCapability, SessionModelOptions } from "@/lib/types"; import type { ModelOptionsCapability, SessionModelOptions } from "@/lib/types";
@@ -58,13 +59,19 @@ function ReasoningEffortControl({ options, selected, mode, onChange }: {
} }
if (mode === "custom" && last > 0) { if (mode === "custom" && last > 0) {
return ( return (
<label className="reasoning-effort flex-1 justify-between text-xs"> <div className="reasoning-effort flex-1 justify-between text-xs">
<span className="min-w-0 truncate" title={label}>{label}</span> <span className="min-w-0 truncate" title={label}>{label}</span>
<select className="min-h-7 min-w-0 max-w-[55%] shrink-0 truncate rounded-control border border-input bg-background px-2 text-xs text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring max-sm:min-h-11" <Select value={String(selected)} onValueChange={(index) => onChange(options[Number(index)])}>
value={selected} onChange={(event) => onChange(options[Number(event.currentTarget.value)])}> <SelectTrigger aria-label={label} className="h-7 min-w-0 max-w-[55%] shrink-0 px-2 text-xs max-sm:h-11">
{options.map((option, index) => <option key={index} value={index}>{option ?? auto}</option>)} <SelectValue />
</select> </SelectTrigger>
</label> <SelectContent>
{options.map((option, index) => (
<SelectItem key={index} value={String(index)} className="max-sm:min-h-11">{option ?? auto}</SelectItem>
))}
</SelectContent>
</Select>
</div>
); );
} }
return ( return (
@@ -49,10 +49,12 @@ it("keeps a custom preset effort selectable without giving it a position on the
const onChange = vi.fn(); const onChange = vi.fn();
render(<Control defaultEffort="extended" onChange={onChange} />); render(<Control defaultEffort="extended" onChange={onChange} />);
const effort = screen.getByRole("combobox", { name: "Reasoning effort" }); const effort = screen.getByRole("combobox", { name: "Reasoning effort" });
expect(effort).toHaveDisplayValue("extended"); expect(effort).toHaveTextContent("extended");
fireEvent.change(effort, { target: { value: "1" } }); fireEvent.keyDown(effort, { key: "Enter" });
expect(effort).toHaveDisplayValue("medium"); fireEvent.click(screen.getByRole("option", { name: "medium" }));
fireEvent.change(effort, { target: { value: "3" } }); expect(effort).toHaveTextContent("medium");
fireEvent.keyDown(effort, { key: "Enter" });
fireEvent.click(screen.getByRole("option", { name: "extended" }));
expect(onChange).toHaveBeenLastCalledWith({ reasoning_effort: "extended", codex_fast_mode: null }); expect(onChange).toHaveBeenLastCalledWith({ reasoning_effort: "extended", codex_fast_mode: null });
}); });