feat(webui): expand and organize settings with autosave (#5704)

* feat(webui): expand settings with autosave and live configuration

* feat(memory): add long-term memory and idle compaction switches

* refactor(webui): clarify settings hierarchy and align compact controls

* refactor(webui): keep only memory consolidation in memory settings

* refactor(webui): defer runtime changes until explicit restart

* refactor(webui): remove default workspace setting

* fix(webui): align model lists and remove preset counters

* fix(i18n): use natural Chinese labels for chat platforms

* fix(i18n): shorten chat settings navigation label

* fix(webui): match settings navigation icons to text size

* refactor(webui): remove redundant settings sidebar heading

* refactor(webui): use icon-only back navigation in settings

* fix(webui): remove back arrow hover hint

* refactor(webui): remove redundant overview details

* refactor(webui): hide secondary descriptions in settings rows

* style(webui): replace settings dividers with rounded highlights

* refactor(webui): remove redundant model list subtitles and badges

* fix(i18n): restore chat translation namespace boundaries

* fix(i18n): complete settings translations for all locales

* fix(webui): reveal settings only for enabled capabilities

* fix(webui): consolidate capabilities and isolate settings feedback

* fix(webui): clear restart notices when settings are reverted

* fix(webui): anchor restart controls in settings sidebar

* fix(webui): shorten sidebar restart label

* fix(webui): align settings spacing and control sizes

* refactor(webui): unify settings dialogs and interaction feedback

* fix(webui): keep settings option groups on one line without scrolling

* refactor(webui): align settings spacing and sidebar icon proportions

* style(webui): match main sidebar typography to settings

* style(webui): use monospace for sidebar session handles

* refactor(webui): remove heartbeat configuration from automations

* feat(webui): expose configuration actions beside capability toggles

* style(webui): remove ellipsis from configuration actions

* refactor(webui): remove redundant app configuration controls

* feat(webui): add compact sidebar navigation and shortcut hints

* fix(webui): synchronize npm dependency lockfile

* test(webui): align input radius expectation with pill styling

* feat(webui): show daily token usage and cache breakdown

* feat(webui): add model usage details and cache hit rates

* feat(webui): chart daily token usage by model

* refactor(webui): simplify usage details and model labels

* fix(webui): hide usage dialog date range

* refactor(webui): consolidate model usage into chart legends

* fix(webui): enforce restart choices and correct settings test route

* fix(webui): polish settings localization and controls

* fix(webui): avoid repeated usage legend labels

* fix(webui): skip empty usage columns in keyboard navigation

* test(webui): assert settings behavior positively

* feat(webui): refine sidebar navigation and add drag resizing

* style(webui): soften sidebar scroll edges

* style(webui): harmonize sidebar typography and text colors

* feat(webui): move channels to the main sidebar

* style(webui): remove dotted underlines from settings hints

* fix(webui): unify tooltip hover delay

* fix(webui): support Seatbelt sandbox settings

* fix(webui): remove unused appearance density preference

* fix(webui): align settings input values consistently

* style(webui): group compact settings controls before inputs

* feat(webui): edit multiline settings in compact dialogs

* feat(webui): add continuous settings scrolling with gentle snapping

* Revert "feat(webui): add continuous settings scrolling with gentle snapping"

This reverts commit f0978c261a53c844185eeab4d0c3190fbd196fe6.
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-10 11:10:51 +08:00
1 parent 20f115bf46
commit 8ea683679d
244 files changed
+6929 -3900

No files matched your search

+39 -104
View File
@@ -109,7 +109,6 @@ describe("Settings models", () => {
expect(within(editor).getByRole("textbox", { name: "Preset name" })).toHaveValue(
"openai",
);
expect(within(editor).queryByText("minimax")).not.toBeInTheDocument();
});
it("edits a legacy case-conflicting preset without treating its own name as a rename", async () => {
@@ -150,7 +149,6 @@ describe("Settings models", () => {
20_000,
);
});
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
});
it("renames an existing preset without losing the editor selection", async () => {
@@ -223,12 +221,8 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models" });
expect(screen.queryByText("Edit preset")).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: /Advanced options/ })).not.toBeInTheDocument();
await togglePresetEditor();
const advanced = await screen.findByRole("button", { name: /Advanced options/ });
expect(screen.queryByText("Context window")).not.toBeInTheDocument();
expect(screen.queryByText("Temperature")).not.toBeInTheDocument();
fireEvent.click(advanced);
@@ -245,7 +239,7 @@ describe("Settings models", () => {
expect(reasoningEffort).toHaveValue("provider-native-mode");
});
it("expands the model preset editor directly below the selected row", async () => {
it("opens the preset editor in a dialog and protects the primary preset", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async (input: RequestInfo | URL) => {
@@ -265,23 +259,15 @@ describe("Settings models", () => {
const row = await screen.findByTestId("model-call-order-row-primary");
const trigger = within(row).getAllByRole("button")[0];
expect(screen.queryByTestId("model-preset-editor")).not.toBeInTheDocument();
expect(trigger).toHaveAttribute("aria-expanded", "false");
expect(trigger).toHaveAttribute("aria-haspopup", "dialog");
fireEvent.click(trigger);
const editor = screen.getByTestId("model-preset-editor");
expect(trigger).toHaveAttribute("aria-pressed", "true");
expect(trigger).toHaveAttribute("aria-expanded", "true");
expect(trigger).toHaveAttribute("aria-controls", "model-preset-editor");
expect(row.parentElement).toHaveAttribute("role", "listitem");
expect(row.parentElement?.parentElement).toHaveAttribute("role", "list");
expect(row.nextElementSibling).toBe(editor);
expect(editor).toHaveClass(
"slide-in-from-top-1",
"lg:max-w-6xl",
"rounded-floating",
);
expect(row.closest('[role="listitem"]')).toBeInTheDocument();
expect(row.closest('[role="list"]')).toBeInTheDocument();
expect(screen.getByRole("dialog", { name: "primary" })).toContainElement(editor);
expect(within(editor).getByRole("textbox", { name: "Preset name" })).toHaveValue(
"primary",
);
@@ -289,13 +275,10 @@ describe("Settings models", () => {
expect(deleteButton).toBeDisabled();
expect(deleteButton).toHaveAttribute("aria-describedby", "model-preset-delete-hint");
expect(
within(editor).getByText("Remove this preset from the call order before deleting it."),
within(editor).getByText("Choose another primary preset before deleting this one."),
).toBeInTheDocument();
fireEvent.click(trigger);
expect(trigger).toHaveAttribute("aria-expanded", "false");
expect(screen.queryByTestId("model-preset-editor")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
});
it("drags model presets to reorder and saves the model call order immediately", async () => {
@@ -344,19 +327,12 @@ describe("Settings models", () => {
fireEvent.change(screen.getByLabelText("Temperature"), {
target: { value: "0.4" },
});
const primaryRow = screen.getByTestId("model-call-order-row-primary");
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
const backupRow = screen.getByTestId("model-call-order-row-backup");
expect(backupRow).toHaveAttribute("draggable", "true");
expect(screen.queryByRole("button", { name: "Move up" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Move down" })).not.toBeInTheDocument();
const dataTransfer = {
dropEffect: "move",
effectAllowed: "move",
setData: vi.fn(),
};
fireEvent.dragStart(backupRow, { dataTransfer });
fireEvent.dragEnter(primaryRow, { dataTransfer });
fireEvent.drop(primaryRow, { dataTransfer });
fireEvent.pointerDown(backupRow, { button: 0, clientY: 100, pointerId: 1 });
fireEvent.pointerMove(backupRow, { clientY: 40, pointerId: 1, buttons: 1 });
fireEvent.pointerUp(backupRow, { pointerId: 1 });
fireEvent.click(backupRow);
await waitFor(() => {
expect(requestMutationMock).toHaveBeenCalledWith(
@@ -366,7 +342,8 @@ describe("Settings models", () => {
);
});
expect(screen.queryByRole("button", { name: "Save order" })).not.toBeInTheDocument();
fireEvent.click(within(screen.getByTestId("model-call-order-row-primary")).getByRole("button"));
fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
expect(screen.getByLabelText("Temperature")).toHaveValue(0.4);
expect(screen.getByRole("button", { name: "Save" })).toBeEnabled();
});
@@ -418,24 +395,17 @@ describe("Settings models", () => {
const primaryRow = screen.getByTestId("model-call-order-row-primary");
const backupRows = screen.getAllByTestId("model-call-order-row-backup");
const firstBackupRow = backupRows[0];
const secondBackupRow = backupRows[1];
const secondBackupTrigger = within(secondBackupRow).getAllByRole("button")[0];
fireEvent.click(secondBackupTrigger);
expect(screen.getAllByTestId("model-preset-editor")).toHaveLength(1);
expect(secondBackupRow.nextElementSibling).toBe(
screen.getByTestId("model-preset-editor"),
);
fireEvent.click(secondBackupTrigger);
expect(screen.getByRole("dialog", { name: "backup" })).toContainElement(screen.getByTestId("model-preset-editor"));
expect(screen.getByRole("button", { name: "Delete", exact: true })).toBeDisabled();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
const dataTransfer = {
dropEffect: "move",
effectAllowed: "move",
setData: vi.fn(),
};
fireEvent.dragStart(primaryRow, { dataTransfer });
fireEvent.dragEnter(firstBackupRow, { dataTransfer });
fireEvent.drop(firstBackupRow, { dataTransfer });
fireEvent.pointerDown(primaryRow, { button: 0, clientY: 100, pointerId: 1 });
fireEvent.pointerMove(primaryRow, { clientY: 40, pointerId: 1, buttons: 1 });
fireEvent.pointerUp(primaryRow, { pointerId: 1 });
await waitFor(() =>
expect(
@@ -528,11 +498,7 @@ describe("Settings models", () => {
const codexRow = await screen.findByTestId("model-call-order-row-codex");
expect(codexRow).toHaveTextContent("codex");
expect(codexRow).not.toHaveTextContent("Codex");
expect(codexRow).toHaveTextContent("openai-codex/gpt-5.5");
expect(codexRow).toHaveTextContent("Disabled");
expect(codexRow).toHaveAttribute("draggable", "false");
expect(screen.queryByRole("button", { name: "Add preset" })).not.toBeInTheDocument();
expect(codexRow).toHaveAttribute("tabindex", "-1");
const enableSwitch = within(codexRow).getByRole("switch", { name: "Enable preset" });
expect(enableSwitch).not.toBeChecked();
@@ -546,13 +512,10 @@ describe("Settings models", () => {
);
});
const enabledCodexRow = await screen.findByTestId("model-call-order-row-codex");
expect(enabledCodexRow).not.toHaveTextContent("Disabled");
expect(enabledCodexRow).not.toHaveTextContent(/Fallback/);
expect(enabledCodexRow).toHaveAttribute("draggable", "true");
expect(enabledCodexRow).toHaveAttribute("tabindex", "0");
expect(
within(enabledCodexRow).getByRole("switch", { name: "Disable preset" }),
).toBeChecked();
expect(screen.queryByText("Up to date.")).not.toBeInTheDocument();
});
it("appends a new model preset to the call order immediately", async () => {
@@ -603,11 +566,8 @@ describe("Settings models", () => {
),
);
fireEvent.click(screen.getByRole("button", { name: "New model preset" }));
expect(screen.queryByRole("dialog", { name: "New model preset" })).not.toBeInTheDocument();
expect(screen.getByRole("dialog", { name: "New model preset" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
expect(
screen.queryByText("Complete the preset before saving."),
).not.toBeInTheDocument();
fireEvent.change(screen.getByRole("textbox", { name: "Preset name" }), {
target: { value: "Writer" },
});
@@ -631,11 +591,9 @@ describe("Settings models", () => {
);
});
const writerRow = await screen.findByTestId("model-call-order-row-Writer");
expect(writerRow).not.toHaveTextContent("Disabled");
expect(writerRow).not.toHaveTextContent(/Fallback/);
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
expect(within(writerRow).getByRole("switch", { name: "Disable preset" })).toBeChecked();
expect(screen.getAllByText("Writer").length).toBeGreaterThan(0);
expect(screen.queryByRole("button", { name: "Save order" })).not.toBeInTheDocument();
});
it("shows an inline error when a new preset name already exists", async () => {
@@ -670,7 +628,6 @@ describe("Settings models", () => {
fireEvent.change(nameInput, { target: { value: "Writer" } });
expect(nameInput).toHaveAttribute("aria-invalid", "false");
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
});
it("converts legacy model settings into presets before editing call order", async () => {
@@ -719,11 +676,6 @@ describe("Settings models", () => {
20_000,
),
);
expect(
screen.queryByRole("button", { name: "Convert to presets" }),
).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Save order" })).not.toBeInTheDocument();
expect(screen.queryByText("Default")).not.toBeInTheDocument();
});
it("starts fresh users with an empty preset list instead of legacy conversion", async () => {
@@ -762,10 +714,6 @@ describe("Settings models", () => {
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 () => {
@@ -832,10 +780,7 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models", initialSettings: payload });
expect((await screen.findAllByText("MiniMax-M3")).length).toBeGreaterThan(0);
expect(screen.getAllByText("fast").length).toBeGreaterThan(0);
expect(screen.queryByText("Default")).not.toBeInTheDocument();
expect(screen.queryByText("openai-codex/gpt-5.5")).not.toBeInTheDocument();
});
it("does not expose the synthetic default preset in the overview summary", async () => {
@@ -862,7 +807,6 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "overview", initialSettings: payload });
expect(await screen.findByText("openai/gpt-4o")).toBeInTheDocument();
expect(screen.queryByText("openai · default")).not.toBeInTheDocument();
expect(screen.getByText("openai")).toBeInTheDocument();
});
@@ -879,9 +823,7 @@ describe("Settings models", () => {
}),
});
expect((await screen.findAllByText("companyProxy/gpt-4o")).length).toBeGreaterThan(0);
expect(screen.getAllByText("Company Proxy").length).toBeGreaterThan(0);
expect(screen.queryByText("Provider setup required")).not.toBeInTheDocument();
});
it("does not treat auto dynamic provider api keys as configured without apiBase", async () => {
@@ -897,11 +839,7 @@ describe("Settings models", () => {
}),
});
expect((await screen.findAllByText("companyProxy/gpt-4o")).length).toBeGreaterThan(0);
expect(screen.getByText("Provider setup required")).toBeInTheDocument();
expect(
screen.queryByText("Configure this provider before saving the preset."),
).not.toBeInTheDocument();
});
it("marks the current model as unconfigured when its provider needs setup", async () => {
@@ -956,7 +894,8 @@ describe("Settings models", () => {
expect(await screen.findByText("Provider setup required")).toBeInTheDocument();
await togglePresetEditor();
expect(screen.getAllByText(/Sign in before saving/).length).toBeGreaterThan(0);
fireEvent.click(screen.getByRole("button", { name: "Sign in required" }));
expect(await screen.findByRole("tooltip")).toHaveTextContent(/Sign in before saving/);
expect(await screen.findByRole("button", { name: "Sign in" })).toBeInTheDocument();
});
@@ -1033,16 +972,10 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models" });
await togglePresetEditor();
const deepseekButtons = await screen.findAllByRole("button", { name: /DeepSeek/ });
const providerPicker = deepseekButtons.find(
(button) => button.getAttribute("aria-haspopup") === "menu",
);
if (!providerPicker) throw new Error("provider picker was not found");
fireEvent.pointerDown(providerPicker);
const providerPicker = await screen.findByRole("combobox", { name: /DeepSeek/ });
fireEvent.keyDown(providerPicker, { key: "ArrowDown" });
expect(await screen.findByRole("menuitem", { name: /DeepSeek/ })).toBeInTheDocument();
expect(screen.queryByRole("menuitem", { name: /OpenAI Codex/ })).not.toBeInTheDocument();
expect(screen.queryByRole("menuitem", { name: /GitHub Copilot/ })).not.toBeInTheDocument();
expect(await screen.findByRole("option", { name: /DeepSeek/ })).toBeInTheDocument();
});
it("does not fetch model lists for unsigned OAuth providers", async () => {
@@ -1243,7 +1176,7 @@ describe("Settings models", () => {
await togglePresetEditor();
const modelButtons = await screen.findAllByRole("button", { name: /orcarouter\/auto/i });
await openPopover(modelButtons[modelButtons.length - 1]);
expect(await screen.findByText("Search provider catalog to choose a model.")).toBeInTheDocument();
expect(await screen.findByText("Search this provider’s model catalog.")).toBeInTheDocument();
expect(
fetchMock.mock.calls.some(([input]) =>
String(input).startsWith("/api/settings/provider-models"),
@@ -1418,9 +1351,13 @@ describe("Settings models", () => {
"/api/settings/provider-models?provider=xai_grok",
expect.objectContaining({ headers: { Authorization: "Bearer tok" } }),
);
fireEvent.keyDown(document.activeElement!, { key: "Escape" });
await waitFor(() => expect(modelButtons[modelButtons.length - 1]).toHaveFocus());
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
await waitFor(() => expect(within(screen.getByTestId("model-call-order-row-primary")).getAllByRole("button")[0]).toBeVisible());
});
it("creates presets in the inline editor and can cancel without opening a dialog", async () => {
it("creates presets in a dialog and can cancel", async () => {
const payload = settingsPayload();
payload.providers = [{ name: "openai", label: "OpenAI", configured: true }];
vi.stubGlobal(
@@ -1441,20 +1378,18 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models" });
const createButton = await screen.findByRole("button", { name: "New model preset" });
const previousPointerEvents = document.body.style.pointerEvents;
expect(createButton).toHaveClass("w-full");
fireEvent.click(createButton);
expect(screen.queryByRole("dialog", { name: "New model preset" })).not.toBeInTheDocument();
expect(screen.getByTestId("model-preset-editor")).toHaveClass("mt-3", "mb-3");
expect(screen.getByRole("dialog", { name: "New model preset" })).toBeInTheDocument();
expect(screen.getByRole("dialog")).toContainElement(screen.getByTestId("model-preset-editor"));
expect(screen.getByRole("textbox", { name: "Preset name" })).toHaveValue("");
expect(screen.queryByText("Temperature")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
expect(screen.getByText("Temperature")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.queryByDisplayValue("Primary")).not.toBeInTheDocument();
expect(screen.queryByText("Edit preset")).not.toBeInTheDocument();
expect(document.body.style.pointerEvents).not.toBe("none");
await waitFor(() => expect(document.body.style.pointerEvents).toBe(previousPointerEvents));
fireEvent.click(screen.getByRole("button", { name: "New model preset" }));
const nameInput = await screen.findByRole("textbox", { name: "Preset name" });