fix(webui): keep the reasoning slider visible while levels load (#6707)
This commit is contained in:
1 parent
f6f49ccca5
commit
d1e1d7bc5e
6 files changed
+65
-14
No files matched your search
@@ -12,6 +12,7 @@ import { createStreamClient } from "@/tests/stream-client";
|
|||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
const isChinese = params.get("lang")?.startsWith("zh");
|
const isChinese = params.get("lang")?.startsWith("zh");
|
||||||
const showSettings = params.has("settings");
|
const showSettings = params.has("settings");
|
||||||
|
const loadCodexCatalog = params.has("codex-catalog");
|
||||||
const providers = {
|
const providers = {
|
||||||
openai_codex: { label: "OpenAI Codex", auth_type: "oauth", codex_fast_mode_supported: true, codex_ultrafast_models: ["gpt-6.2-sol"] },
|
openai_codex: { label: "OpenAI Codex", auth_type: "oauth", codex_fast_mode_supported: true, codex_ultrafast_models: ["gpt-6.2-sol"] },
|
||||||
github_copilot: { label: "GitHub Copilot", auth_type: "oauth" },
|
github_copilot: { label: "GitHub Copilot", auth_type: "oauth" },
|
||||||
@@ -69,13 +70,15 @@ const groups = [
|
|||||||
] },
|
] },
|
||||||
];
|
];
|
||||||
const group = groups.find(({ id }) => id === params.get("group")) ?? groups[0]!;
|
const group = groups.find(({ id }) => id === params.get("group")) ?? groups[0]!;
|
||||||
const base = group.id === "oauth" ? (params.has("ultrafast") ? ultrafastCodex : standardCodex) : group.presets[0]!;
|
const base = loadCodexCatalog
|
||||||
|
? preset("Review", "openai_codex", "openai-codex/gpt-6.2-sol", "xhigh", ["low", "medium", "high"], { default: false, ultrafast_supported: true })
|
||||||
|
: group.id === "oauth" ? (params.has("ultrafast") ? ultrafastCodex : standardCodex) : group.presets[0]!;
|
||||||
const settings: SettingsPayload = {
|
const settings: SettingsPayload = {
|
||||||
...baseSettings,
|
...baseSettings,
|
||||||
agent: { ...baseSettings.agent, model: base.model, provider: base.provider, resolved_provider: base.provider,
|
agent: { ...baseSettings.agent, model: base.model, provider: base.provider, resolved_provider: base.provider,
|
||||||
reasoning_effort: base.reasoning_effort },
|
reasoning_effort: base.reasoning_effort },
|
||||||
providers: Object.entries(providers).map(([name, provider]) => ({
|
providers: Object.entries(providers).map(([name, provider]) => ({
|
||||||
name, configured: true, model_catalog: "unsupported", ...provider,
|
name, configured: true, model_catalog: loadCodexCatalog && name === "openai_codex" ? "hybrid" : "unsupported", ...provider,
|
||||||
})),
|
})),
|
||||||
model_presets: [{ ...base, name: "default", label: "Default", active: true, is_default: true }, ...group.presets],
|
model_presets: [{ ...base, name: "default", label: "Default", active: true, is_default: true }, ...group.presets],
|
||||||
model_call_order: group.presets.map(({ name }) => name),
|
model_call_order: group.presets.map(({ name }) => name),
|
||||||
@@ -109,8 +112,10 @@ function FixtureNav() {
|
|||||||
|
|
||||||
/** Fully task-local fixture: no real gateway, authentication, or network mutations. */
|
/** Fully task-local fixture: no real gateway, authentication, or network mutations. */
|
||||||
export function installModelOptionsPreviewApi() {
|
export function installModelOptionsPreviewApi() {
|
||||||
window.fetch = async (input) => {
|
const fetch = window.fetch.bind(window);
|
||||||
|
window.fetch = async (input, init) => {
|
||||||
const url = String(input);
|
const url = String(input);
|
||||||
|
if (loadCodexCatalog && url.includes("/api/settings/provider-models?")) return fetch(input, init);
|
||||||
if (url.includes("/webui-thread")) return Response.json({ schemaVersion: 3, projection: "events", events: [] });
|
if (url.includes("/webui-thread")) return Response.json({ schemaVersion: 3, projection: "events", events: [] });
|
||||||
if (url.includes("/commands")) return Response.json({ commands: [] });
|
if (url.includes("/commands")) return Response.json({ commands: [] });
|
||||||
if (url.includes("/api/settings")) return Response.json(settings);
|
if (url.includes("/api/settings")) return Response.json(settings);
|
||||||
|
|||||||
@@ -195,6 +195,35 @@ test("provider examples switch from Codex to direct API and gateway capabilities
|
|||||||
await expect(reasoning).toHaveAttribute("aria-valuetext", "Auto");
|
await expect(reasoning).toHaveAttribute("aria-valuetext", "Auto");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("keeps the reasoning slider track visible while a Codex preset awaits its effort levels", async ({ page }) => {
|
||||||
|
const catalogUrl = /\/api\/settings\/provider-models\?provider=openai_codex$/;
|
||||||
|
let releaseCatalog!: () => void;
|
||||||
|
const catalogGated = new Promise<void>((resolve) => { releaseCatalog = resolve; });
|
||||||
|
await page.route(catalogUrl, async (route) => {
|
||||||
|
await catalogGated;
|
||||||
|
await route.fulfill({ json: {
|
||||||
|
provider: "openai_codex", label: "OpenAI Codex", status: "available", catalog_kind: "hybrid", source: "remote", model_count: 1,
|
||||||
|
models: [{ id: "openai-codex/gpt-6.2-sol", reasoning_efforts: ["low", "medium", "high", "xhigh", "max", "ultra"] }],
|
||||||
|
} });
|
||||||
|
});
|
||||||
|
await page.goto("/browser/fixture.html?case=model-options&codex-catalog");
|
||||||
|
const dialog = page.getByRole("dialog", { name: "Switch model", exact: true });
|
||||||
|
const effort = dialog.getByRole("slider", { name: "Reasoning effort" });
|
||||||
|
try {
|
||||||
|
await Promise.all([page.waitForRequest(catalogUrl), page.getByRole("button", { name: "Default", exact: true }).click()]);
|
||||||
|
await expect(dialog.locator(".reasoning-effort-track")).toBeVisible();
|
||||||
|
await expect(dialog.getByText("xhigh", { exact: true })).toBeVisible();
|
||||||
|
await expect(dialog.getByRole("combobox", { name: "Reasoning effort" })).toHaveCount(0);
|
||||||
|
await expect(effort).toHaveCount(0);
|
||||||
|
await expect(dialog.getByRole("button", { name: "Fast", exact: true })).toBeEnabled();
|
||||||
|
} finally {
|
||||||
|
releaseCatalog();
|
||||||
|
}
|
||||||
|
await expect(effort).toHaveAttribute("aria-valuetext", "xhigh");
|
||||||
|
await effort.press("ArrowLeft");
|
||||||
|
await expect(effort).toHaveAttribute("aria-valuetext", "high");
|
||||||
|
});
|
||||||
|
|
||||||
test("keeps the custom reasoning effort as a concrete value for a self-hosted preset", async ({ page }) => {
|
test("keeps the custom reasoning effort as a concrete value for a self-hosted preset", async ({ page }) => {
|
||||||
await page.goto("/browser/fixture.html?case=model-options&group=local");
|
await page.goto("/browser/fixture.html?case=model-options&group=local");
|
||||||
await page.getByRole("button", { name: "Default", exact: true }).click();
|
await page.getByRole("button", { name: "Default", exact: true }).click();
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import type { ModelOptionsCapability, SessionModelOptions } from "@/lib/types";
|
|||||||
import "./model-options-control.css";
|
import "./model-options-control.css";
|
||||||
|
|
||||||
export interface ModelOptionsControlProps {
|
export interface ModelOptionsControlProps {
|
||||||
data: { value: SessionModelOptions; capability: ModelOptionsCapability; efforts: string[] } | null;
|
data: { value: SessionModelOptions; capability: ModelOptionsCapability; efforts: string[]; effortsPending: boolean } | null;
|
||||||
onChange: (value: SessionModelOptions) => void;
|
onChange: (value: SessionModelOptions) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReasoningEffortControl({ options, selected, ordered, onChange }: {
|
function ReasoningEffortControl({ options, selected, mode, onChange }: {
|
||||||
options: (string | null)[];
|
options: (string | null)[];
|
||||||
selected: number;
|
selected: number;
|
||||||
ordered: boolean;
|
mode: "ordered" | "pending" | "custom";
|
||||||
onChange: (value: string | null) => void;
|
onChange: (value: string | null) => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -56,7 +56,7 @@ function ReasoningEffortControl({ options, selected, ordered, onChange }: {
|
|||||||
drag.current = null;
|
drag.current = null;
|
||||||
setPreview(null);
|
setPreview(null);
|
||||||
}
|
}
|
||||||
if (!ordered && last > 0) {
|
if (mode === "custom" && last > 0) {
|
||||||
return (
|
return (
|
||||||
<label className="reasoning-effort flex-1 justify-between text-xs">
|
<label 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>
|
||||||
@@ -70,7 +70,16 @@ function ReasoningEffortControl({ options, selected, ordered, onChange }: {
|
|||||||
return (
|
return (
|
||||||
<div className="reasoning-effort text-xs">
|
<div className="reasoning-effort text-xs">
|
||||||
<span className="min-w-0 truncate" title={label}>{label}</span>
|
<span className="min-w-0 truncate" title={label}>{label}</span>
|
||||||
{last > 0 ? (
|
{mode === "pending" ? (
|
||||||
|
<div className="reasoning-effort-slider" data-pending style={{ "--effort-steps": Math.max(last, 1) } as CSSProperties}>
|
||||||
|
<div className="reasoning-effort-track col-start-1 row-start-1" aria-hidden="true">
|
||||||
|
<div className="reasoning-effort-lane" />
|
||||||
|
</div>
|
||||||
|
<span className="relative col-start-1 row-start-1 truncate px-2 text-center font-medium text-foreground" title={selectedLabel}>
|
||||||
|
{selectedLabel}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : last > 0 ? (
|
||||||
<div className="reasoning-effort-slider" data-dragging={preview !== null || undefined}
|
<div className="reasoning-effort-slider" data-dragging={preview !== null || undefined}
|
||||||
data-at-start={position === 0 || undefined}
|
data-at-start={position === 0 || undefined}
|
||||||
style={{ "--effort-progress": position, "--effort-steps": last } as CSSProperties}
|
style={{ "--effort-progress": position, "--effort-steps": last } as CSSProperties}
|
||||||
@@ -115,7 +124,7 @@ function ReasoningEffortControl({ options, selected, ordered, onChange }: {
|
|||||||
|
|
||||||
export function ModelOptionsControl({ data, onChange }: ModelOptionsControlProps) {
|
export function ModelOptionsControl({ data, onChange }: ModelOptionsControlProps) {
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
const { value, capability, efforts } = data;
|
const { value, capability, efforts, effortsPending } = data;
|
||||||
const defaultEffort = capability.reasoning_effort.default;
|
const defaultEffort = capability.reasoning_effort.default;
|
||||||
const effectiveEffort = value.reasoning_effort ?? defaultEffort;
|
const effectiveEffort = value.reasoning_effort ?? defaultEffort;
|
||||||
// Keep preset and session values selectable even if they aren't in the model catalog.
|
// Keep preset and session values selectable even if they aren't in the model catalog.
|
||||||
@@ -123,11 +132,12 @@ export function ModelOptionsControl({ data, onChange }: ModelOptionsControlProps
|
|||||||
const speed = capability.codex_fast_mode;
|
const speed = capability.codex_fast_mode;
|
||||||
if (!values.length && !speed) return null;
|
if (!values.length && !speed) return null;
|
||||||
const options = defaultEffort === null ? [null, ...values] : values;
|
const options = defaultEffort === null ? [null, ...values] : values;
|
||||||
|
const mode = values.every((effort) => efforts.includes(effort)) ? "ordered" : effortsPending ? "pending" : "custom";
|
||||||
return (
|
return (
|
||||||
<div className="model-options-row mt-1 flex items-center gap-1 border-t border-border/55 px-2 py-1">
|
<div className="model-options-row mt-1 flex items-center gap-1 border-t border-border/55 px-2 py-1">
|
||||||
{values.length > 0 ? (
|
{values.length > 0 ? (
|
||||||
<ReasoningEffortControl options={options} selected={options.indexOf(effectiveEffort)}
|
<ReasoningEffortControl options={options} selected={options.indexOf(effectiveEffort)}
|
||||||
ordered={values.every((effort) => efforts.includes(effort))}
|
mode={mode}
|
||||||
onChange={(reasoning_effort) => onChange({ ...value, reasoning_effort })} />
|
onChange={(reasoning_effort) => onChange({ ...value, reasoning_effort })} />
|
||||||
) : null}
|
) : null}
|
||||||
{speed ? (
|
{speed ? (
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
touch-action: pan-y pinch-zoom;
|
touch-action: pan-y pinch-zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reasoning-effort-slider[data-pending] {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
.reasoning-effort-track {
|
.reasoning-effort-track {
|
||||||
--effort-lane: #e6e5e6;
|
--effort-lane: #e6e5e6;
|
||||||
--effort-lane-edge: #dad9da;
|
--effort-lane-edge: #dad9da;
|
||||||
|
|||||||
@@ -76,11 +76,14 @@ export function useSessionModelOptions({ sessionKey, preset, settings, open, dis
|
|||||||
const providerName = configuration?.resolved_provider ?? configuration?.provider;
|
const providerName = configuration?.resolved_provider ?? configuration?.provider;
|
||||||
const provider = settings?.providers.find((entry) => entry.name === providerName);
|
const provider = settings?.providers.find((entry) => entry.name === providerName);
|
||||||
const model = configuration?.model ?? "";
|
const model = configuration?.model ?? "";
|
||||||
const { payload } = useProviderModelCatalog({
|
const canLoadCatalog = enabled && !!capability && !!model && !!provider?.configured && provider.model_catalog !== "unsupported";
|
||||||
|
const { payload, loading, failed } = useProviderModelCatalog({
|
||||||
revision: provider ?? NO_PROVIDER, token, provider: provider?.name ?? "",
|
revision: provider ?? NO_PROVIDER, token, provider: provider?.name ?? "",
|
||||||
enabled: enabled && open && !!capability && !!model && !!provider?.configured && provider.model_catalog !== "unsupported",
|
enabled: canLoadCatalog && open,
|
||||||
});
|
});
|
||||||
const efforts = reasoningEffortValues(payload, model, capability?.reasoning_effort.values);
|
const efforts = reasoningEffortValues(payload, model, capability?.reasoning_effort.values);
|
||||||
|
// The popover renders its contents before it starts the lazy catalog request.
|
||||||
|
const effortsPending = canLoadCatalog && (loading || (!payload && !failed));
|
||||||
const select = useCallback((options: SessionModelOptions) => {
|
const select = useCallback((options: SessionModelOptions) => {
|
||||||
if (enabled) remember(key, { preset, options });
|
if (enabled) remember(key, { preset, options });
|
||||||
}, [enabled, key, preset, remember]);
|
}, [enabled, key, preset, remember]);
|
||||||
@@ -100,7 +103,7 @@ export function useSessionModelOptions({ sessionKey, preset, settings, open, dis
|
|||||||
// The Gateway owns persisted options. Omission preserves them; null fields explicitly clear them.
|
// The Gateway owns persisted options. Omission preserves them; null fields explicitly clear them.
|
||||||
const sendValue = useCallback(() => enabled ? localOptions : undefined, [enabled, localOptions]);
|
const sendValue = useCallback(() => enabled ? localOptions : undefined, [enabled, localOptions]);
|
||||||
return {
|
return {
|
||||||
data: enabled && capability ? { value, capability, efforts } : null,
|
data: enabled && capability ? { value, capability, efforts, effortsPending } : null,
|
||||||
select, reset, moveToSession, sendValue,
|
select, reset, moveToSession, sendValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ function Control({ fast = true, defaultEffort = "medium", onChange }: {
|
|||||||
}) {
|
}) {
|
||||||
const [value, setValue] = useState<SessionModelOptions>({ reasoning_effort: null, codex_fast_mode: null });
|
const [value, setValue] = useState<SessionModelOptions>({ reasoning_effort: null, codex_fast_mode: null });
|
||||||
const efforts = ["low", "medium", "high"];
|
const efforts = ["low", "medium", "high"];
|
||||||
return <ModelOptionsControl data={{ value, efforts, capability: {
|
return <ModelOptionsControl data={{ value, efforts, effortsPending: false, capability: {
|
||||||
reasoning_effort: { default: defaultEffort, values: efforts },
|
reasoning_effort: { default: defaultEffort, values: efforts },
|
||||||
...(fast ? { codex_fast_mode: { default: true } } : {}),
|
...(fast ? { codex_fast_mode: { default: true } } : {}),
|
||||||
} }} onChange={(next) => { setValue(next); onChange?.(next); }} />;
|
} }} onChange={(next) => { setValue(next); onChange?.(next); }} />;
|
||||||
|
|||||||
Reference in new issue
Block a user