fix(webui): keep schema defaults out of model presets

This commit is contained in:
Xubin Ren
2026-09-02 16:25:07 +08:00
parent 94d62f86a0
commit 0274c11bfb
7 changed files with 169 additions and 6 deletions
@@ -560,7 +560,8 @@ export function ModelsSettings({
{tx("settings.models.presets", "Model presets")}
</SettingsSectionTitle>
<SettingsGroup>
{!settings.model_call_order_editable ? (
{!settings.model_call_order_editable &&
settings.model_configuration_migratable !== false ? (
<div className="flex flex-col gap-4 px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5">
<div className="flex min-w-0 items-start gap-3">
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-control bg-muted text-muted-foreground">
+2
View File
@@ -595,6 +595,8 @@ export interface SettingsPayload {
}>;
model_call_order: string[];
model_call_order_editable: boolean;
/** Whether an actual legacy model configuration is available to convert. */
model_configuration_migratable?: boolean;
created_model_preset?: string;
created_provider?: string;
providers: Array<{
+43
View File
@@ -690,6 +690,7 @@ describe("Settings models", () => {
model_presets: [defaultPreset],
model_call_order: [],
model_call_order_editable: false,
model_configuration_migratable: true,
};
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
const url = String(input);
@@ -725,6 +726,48 @@ describe("Settings models", () => {
expect(screen.queryByText("Default")).not.toBeInTheDocument();
});
it("starts fresh users with an empty preset list instead of legacy conversion", async () => {
const base = settingsPayload();
const freshPayload: SettingsPayload = {
...base,
agent: {
...base.agent,
model: "anthropic/claude-opus-4-5",
provider: "auto",
resolved_provider: null,
has_api_key: false,
model_preset: "default",
},
model_presets: [
{
...base.model_presets[0],
name: "default",
label: "Default",
active: true,
is_default: true,
model: "anthropic/claude-opus-4-5",
provider: "auto",
resolved_provider: null,
},
],
model_call_order: [],
model_call_order_editable: false,
model_configuration_migratable: false,
providers: [],
};
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>(() => {})));
renderSettingsView({ initialSection: "models", initialSettings: freshPayload });
expect(
await screen.findByRole("button", { name: "New model preset" }),
).toBeInTheDocument();
expect(
screen.queryByRole("button", { name: "Convert to presets" }),
).not.toBeInTheDocument();
expect(screen.queryByText("claude-opus-4-5")).not.toBeInTheDocument();
});
it("does not expose the synthetic default configuration as a WebUI preset", async () => {
const base = settingsPayload();
const payload: SettingsPayload = {