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 -52
View File
@@ -166,12 +166,10 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Matrix settings" })).toBeInTheDocument();
expect(screen.queryByText("0 running · 1 channels")).not.toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Matrix settings" }));
expect(screen.getAllByText("Failed").length).toBeGreaterThan(0);
expect(screen.queryByText("Enabled, support needs install")).not.toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Matrix channel" })).toHaveAttribute("aria-checked", "false");
expect(screen.getByLabelText("Matrix channel")).toHaveAttribute("aria-checked", "false");
fireEvent.click(screen.getByRole("button", { name: "Install support" }));
fireEvent.click(screen.getByRole("button", { name: "Install and enable" }));
@@ -219,11 +217,10 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Matrix settings" })).toBeInTheDocument();
expect(screen.queryByText("0 running · 1 channels")).not.toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Matrix settings" }));
expect(screen.getAllByText("Failed").length).toBeGreaterThan(0);
expect(screen.getByText(runtimeError)).toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Matrix channel" })).toHaveAttribute(
expect(screen.getByLabelText("Matrix channel")).toHaveAttribute(
"aria-checked",
"false",
);
@@ -268,8 +265,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Feishu settings" })).toBeInTheDocument();
expect(screen.queryByText("nanobot channels login feishu")).not.toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Feishu settings" }));
fireEvent.click(await screen.findByRole(
"button",
{ name: "nanobot" },
@@ -327,7 +323,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Feishu settings" })).toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Feishu settings" }));
fireEvent.click(await screen.findByRole(
"button",
{ name: "nanobot" },
@@ -416,6 +412,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click((await screen.findAllByRole("button", { name: /^View .+ settings$/ }))[0]);
fireEvent.click(await screen.findByRole("button", { name: "nanobot" }));
fireEvent.click(await screen.findByRole("switch", { name: "nanobot assistant" }));
@@ -505,6 +502,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click((await screen.findAllByRole("button", { name: /^View .+ settings$/ }))[0]);
expect(await screen.findByText("Product Helper")).toBeInTheDocument();
expect(screen.getAllByText("Support Bot")).toHaveLength(1);
expect(document.querySelector('img[src="https://example.com/support.png"]')).toBeTruthy();
@@ -518,14 +516,13 @@ describe("Settings channels", () => {
"false",
);
expect(screen.queryByText("cli_def...ault")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: /Support Bot/ }));
expect(screen.getByRole("button", { name: /Support Bot/ })).toHaveAttribute(
"aria-expanded",
"true",
);
expect(screen.getAllByText("cli_def...ault").length).toBeGreaterThan(0);
expect(screen.getByText("Advanced")).toBeInTheDocument();
expect(screen.getByText("Advanced", { selector: "summary span" })).toBeInTheDocument();
expect(screen.getByText("Topic isolation")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: /Product Helper/ }));
@@ -601,8 +598,8 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click((await screen.findAllByRole("button", { name: /^View .+ settings$/ }))[0]);
expect(await screen.findByText("Default worker")).toBeInTheDocument();
expect(screen.queryByRole("switch", { name: "Multi Plugin channel" })).not.toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Default worker instance" })).toHaveAttribute(
"aria-checked",
"true",
@@ -665,6 +662,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click((await screen.findAllByRole("button", { name: /^View .+ settings$/ }))[0]);
await screen.findByText("Support Bot");
expect(screen.getAllByText("Support Bot")).toHaveLength(1);
expect(screen.getByText("1 assistant connected")).toBeInTheDocument();
@@ -672,10 +670,8 @@ describe("Settings channels", () => {
"aria-checked",
"true",
);
expect(screen.queryByText("cli_sup...port")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Support Bot" }));
expect(screen.getByText("cli_sup...port")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Replace assistant" })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Reconnect" }));
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
"settings.feature.enable",
@@ -735,15 +731,14 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click((await screen.findAllByRole("button", { name: /^View .+ settings$/ }))[0]);
await screen.findByText("No assistant connected");
expect(screen.queryByText("0 running · 1 channels")).not.toBeInTheDocument();
expect(screen.getAllByText("Failed").length).toBeGreaterThan(0);
expect(screen.getByText(runtimeError)).toBeInTheDocument();
expect(screen.getByRole("switch", { name: "test assistant" })).toHaveAttribute(
"aria-checked",
"false",
);
expect(screen.queryByText("Connected")).not.toBeInTheDocument();
});
it("shows group behavior fields as options", async () => {
@@ -778,8 +773,8 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Discord settings" })).toBeInTheDocument();
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(await screen.findByRole("button", { name: "View Discord settings" }));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
const behavior = screen.getByRole("radiogroup", { name: "Group behavior" });
expect(within(behavior).getByRole("radio", { name: "Mention only" })).toHaveAttribute(
@@ -787,7 +782,6 @@ describe("Settings channels", () => {
"true",
);
expect(within(behavior).getByRole("radio", { name: "All messages" })).toBeInTheDocument();
expect(screen.queryByPlaceholderText("mention")).not.toBeInTheDocument();
fireEvent.click(within(behavior).getByRole("radio", { name: "All messages" }));
@@ -841,22 +835,15 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
const emailRow = await screen.findByRole("button", { name: "View Email settings" });
expect(screen.getByPlaceholderText("Search channels")).toHaveClass(
"focus-visible:ring-2",
"focus-visible:ring-inset",
"focus-visible:ring-ring/50",
);
expect(screen.queryByRole("switch", { name: "Email channel" })).not.toBeInTheDocument();
expect(emailRow).toBeVisible();
expect(screen.getByRole("switch", { name: "Email channel" })).toBeInTheDocument();
fireEvent.click(emailRow);
expect(screen.getByRole("button", { name: "All channels" })).toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Email channel" })).toBeInTheDocument();
expect(screen.queryByPlaceholderText("Search channels")).not.toBeInTheDocument();
expect(screen.getByRole("dialog")).toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "All channels" }));
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
expect(screen.getByPlaceholderText("Search channels")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "View Email settings" })).toBeInTheDocument();
});
@@ -929,16 +916,16 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Discord settings" })).toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Discord settings" }));
expect(screen.getByRole("link", { name: "Open Discord setup" })).toHaveAttribute(
"href",
"https://nanobot.wiki/docs/0.2.2/getting-started/chat-apps#discord",
);
expect(screen.getByRole("switch", { name: "Discord channel" })).toBeDisabled();
expect(screen.getByLabelText("Discord channel")).toBeEnabled();
fireEvent.change(screen.getByPlaceholderText("Discord bot token"), {
target: { value: "discord-token" },
});
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
fireEvent.change(screen.getByLabelText("Allowed channels"), {
target: { value: "123, 456" },
});
@@ -969,7 +956,7 @@ describe("Settings channels", () => {
150_000,
);
expect(await screen.findByText("Checked and enabled.")).toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Discord channel" })).toHaveAttribute(
expect(screen.getByLabelText("Discord channel")).toHaveAttribute(
"aria-checked",
"true",
);
@@ -1033,12 +1020,12 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Discord settings" })).toBeInTheDocument();
expect(screen.getByRole("switch", { name: "Discord channel" })).toHaveAttribute(
fireEvent.click(await screen.findByRole("button", { name: "View Discord settings" }));
expect(screen.getByLabelText("Discord channel")).toHaveAttribute(
"aria-checked",
"false",
);
expect(screen.getByRole("switch", { name: "Discord channel" })).toBeEnabled();
expect(screen.getByLabelText("Discord channel")).toBeEnabled();
expect(screen.getByText("Configured manually")).toBeInTheDocument();
expect(screen.getByText("Saved")).toBeInTheDocument();
const savedSecret = screen.getByPlaceholderText("Saved secret");
@@ -1047,13 +1034,14 @@ describe("Settings channels", () => {
expect(savedSecret.closest("form")).not.toBeNull();
expect(screen.queryByDisplayValue("discord-secret-token")).not.toBeInTheDocument();
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
expect(screen.getByLabelText("Allowed channels")).toHaveValue("123, 456");
expect(within(screen.getByRole("radiogroup", { name: "Group behavior" })).getByRole(
"radio",
{ name: "All messages" },
)).toHaveAttribute("aria-checked", "true");
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
fireEvent.click(screen.getByRole("switch", { name: "Discord channel" }));
await waitFor(() =>
expect(requestMutationMock).toHaveBeenCalledWith(
@@ -1095,7 +1083,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View Telegram settings" })).toBeInTheDocument();
fireEvent.click(await screen.findByRole("button", { name: "View Telegram settings" }));
expect(screen.getByRole("link", { name: "Open Telegram setup" })).toHaveAttribute(
"href",
"https://nanobot.wiki/docs/0.2.2/getting-started/chat-apps#telegram",
@@ -1175,8 +1163,8 @@ describe("Settings channels", () => {
const guide = await screen.findByRole("link", { name: guideLabel });
expect(guide).toHaveAttribute("href", expect.stringMatching(/^https:\/\//));
expect(guide.querySelector("span[aria-hidden] img, span[aria-hidden] svg")).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
}
expect(screen.queryByRole("button", { name: "View MoChat settings" })).not.toBeInTheDocument();
});
it("uses choices for channel enum and boolean fields", async () => {
@@ -1212,17 +1200,17 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click(await screen.findByRole("button", { name: "View Email settings" }));
const consent = screen.getByRole("radiogroup", { name: "Consent granted" });
const consent = screen.getByRole("radiogroup", { name: "Allow nanobot to read and send email" });
expect(within(consent).getByRole("radio", { name: "Not granted" })).toHaveAttribute(
"aria-checked",
"true",
);
expect(within(consent).getByRole("radio", { name: "Granted" })).toBeInTheDocument();
expect(screen.queryByPlaceholderText("true")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
fireEvent.click(screen.getByRole("button", { name: "View Feishu settings" }));
fireEvent.click(screen.getByRole("button", { name: "nanobot" }));
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
const region = screen.getByRole("radiogroup", { name: "Region" });
expect(within(region).getByRole("radio", { name: "Feishu" })).toHaveAttribute(
"aria-checked",
@@ -1230,8 +1218,9 @@ describe("Settings channels", () => {
);
expect(within(region).getByRole("radio", { name: "Lark" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
fireEvent.click(screen.getByRole("button", { name: "View Matrix settings" }));
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
const matrixBehavior = screen.getByRole("radiogroup", { name: "Group behavior" });
expect(within(matrixBehavior).getByRole("radio", { name: "All messages" })).toHaveAttribute(
"aria-checked",
@@ -1239,8 +1228,9 @@ describe("Settings channels", () => {
);
expect(within(matrixBehavior).getByRole("radio", { name: "Allowlist" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
fireEvent.click(screen.getByRole("button", { name: "View QQ settings" }));
fireEvent.click(screen.getByText("Advanced"));
fireEvent.click(screen.getByText("Advanced", { selector: "summary span" }));
const format = screen.getByRole("radiogroup", { name: "Message format" });
expect(within(format).getByRole("radio", { name: "Plain text" })).toHaveAttribute(
"aria-checked",
@@ -1279,13 +1269,10 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
expect(await screen.findByRole("button", { name: "View WebSocket settings" })).toBeInTheDocument();
expect(screen.getAllByText("WebSocket")).toHaveLength(2);
expect(screen.queryByText("Required for WebUI")).not.toBeInTheDocument();
expect(screen.getAllByText("On").length).toBeGreaterThanOrEqual(1);
fireEvent.click(await screen.findByRole("button", { name: "View WebSocket settings" }));
expect(screen.getByRole("heading", { name: "WebSocket", exact: true })).toBeVisible();
expect(screen.getByText("Managed by WebUI")).toBeInTheDocument();
expect(screen.queryByText("Configured manually")).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Disable channel" })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
const websocketSwitch = screen.getByRole("switch", { name: "WebSocket channel" });
expect(websocketSwitch).toBeDisabled();
expect(websocketSwitch).toHaveAttribute("aria-checked", "true");