Skip to content

Your lightweight open-source personal agent.

fix(webui): keep local appearance ready during settings loads

Xubin Ren44a7ef53ce23
diff --git a/docs/webui.md b/docs/webui.md
index c236e7f81..e929ebe3a 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -258,7 +258,7 @@ Local triggers do not have a WebUI "Run now" action because each run needs a mes
Runtime settings may require a gateway restart; the WebUI marks those controls.
-**Appearance** preferences apply immediately in the current browser without changing gateway configuration. Choose **System**, **Light**, or **Dark** for the theme; **System** follows operating-system changes while the app is open. Existing explicit light/dark preferences are preserved.
+**Appearance** preferences apply immediately in the current browser without changing gateway configuration. These controls remain available while gateway settings are loading or unavailable. Choose **System**, **Light**, or **Dark** for the theme; **System** follows operating-system changes while the app is open. Existing explicit light/dark preferences are preserved.
Under **Reading**, choose a small, standard or large preset, or enter a custom size in the inline **Custom** field beside them. Select the field to edit the saved custom value, using whole pixels from 14 to 28. Hovering or focusing the field shows the supported range and how reading sizes apply. An out-of-range or fractional entry is marked invalid when you finish editing, with a hint showing the size still in use; it does not silently clamp or replace your last valid size. The size applies to both desktop and narrow screens. The input retains a 16px minimum on every screen. The live preview uses the same reading typography as conversations: messages, Markdown and code scale together, while navigation and toolbars stay unchanged. Standard remains the default; switching to a preset preserves your custom value for later use. **Activity display** controls how much process and file-edit detail appears, not what the agent executes.
diff --git a/webui/browser/skeleton-additions.spec.ts b/webui/browser/skeleton-additions.spec.ts
index a8de47833..9af17291d 100644
--- a/webui/browser/skeleton-additions.spec.ts
+++ b/webui/browser/skeleton-additions.spec.ts
@@ -55,7 +55,7 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
});
test("settings sections preserve their loaded row layout", async ({ page }, testInfo) => {
- for (const section of ["appearance", "notifications", "capabilities", "runtime", "advanced", "overview", "models", "about"]) {
+ for (const section of ["notifications", "capabilities", "runtime", "advanced", "overview", "models", "about"]) {
const extra = `&section=${section}${section === "notifications" ? "&notificationPermission=granted" : ""}`;
await page.goto(fixture("settings", "loaded", extra));
const target = page.locator("[data-settings-section]");
@@ -78,7 +78,6 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
const loaded = await boxes(target.locator(selector + notificationDetails + proxyForm));
const proxyAddress = section === "advanced" ? await boxes(target.locator('[data-shared-proxy-editor] input')) : null;
const loadedControls = section === "notifications" ? await boxes(target.getByRole("switch")) : null;
- const readingControl = section === "appearance" ? await boxes(target.getByRole("radiogroup")) : null;
await page.goto(fixture("settings", "loading", extra));
await settle(page);
const skeletonSelector = section === "overview" ? "[data-overview-skeleton-row]" : section === "models" ? "[data-model-preset-skeleton], .settings-footer" : section === "about" ? ".settings-list-row" : "[data-settings-skeleton-row]";
@@ -86,7 +85,6 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
const skeleton = await boxes(target.locator(skeletonSelector + notificationDetails + proxySkeleton));
sameBoxes(skeleton, loaded, section);
if (proxyAddress) sameBoxes(await boxes(target.locator("[data-proxy-address-skeleton]")), proxyAddress, "shared proxy address");
- if (readingControl) sameBoxes(await boxes(target.locator("[data-skeleton-reading-size]")), readingControl);
if (loadedControls) {
const skeletonControls = await boxes(target.locator("[data-skeleton-switch]"));
sameBoxes(skeletonControls, loadedControls);
@@ -96,6 +94,35 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
}
});
+ test("appearance stays usable and keeps its layout while gateway settings load or fail", async ({ page }) => {
+ await page.addInitScript(() => localStorage.setItem("nanobot-webui.settings-preferences", JSON.stringify({
+ schemaVersion: 1, readingTextSize: "custom", customReadingTextSize: 24,
+ })));
+ await page.goto(fixture("settings", "loaded", "&section=appearance"));
+ const target = page.locator('[data-settings-section="appearance"]');
+ const ready = async () => {
+ await expect(target.locator("[data-reading-preview-content] strong")).toBeVisible();
+ await expect(target.locator("[data-reading-preview-content] .markdown-content p").first()).toHaveCSS("font-size", "24px");
+ await settle(page);
+ };
+ await ready();
+ const layout = ".appearance-theme-grid, .appearance-reading-card, .appearance-size-options, .settings-row";
+ const loaded = await boxes(target.locator(layout));
+ for (const state of ["loading", "error", "refresh"]) {
+ await page.goto(fixture("settings", state, "&section=appearance"));
+ await ready();
+ sameBoxes(await boxes(target.locator(layout)), loaded, `appearance ${state}`);
+ await expect(status(page)).toHaveCount(0);
+ const input = target.getByRole("spinbutton");
+ await expect(input).toBeEnabled();
+ await expect(input).toHaveValue("24");
+ await input.fill("22");
+ await input.press("Enter");
+ await expect(target.locator("[data-reading-preview-content] .markdown-content p").first()).toHaveCSS("font-size", "22px");
+ expect(await page.evaluate(() => JSON.parse(localStorage.getItem("nanobot-webui.settings-preferences")!).customReadingTextSize)).toBe(22);
+ }
+ });
+
test("calendar and task skeletons retain their toolbar and real date grid", async ({ page }) => {
for (const nextMonth of [false, true]) {
const open = async (state: string) => {
diff --git a/webui/src/components/settings/SettingsPage.tsx b/webui/src/components/settings/SettingsPage.tsx
index 841e73956..03b5eb744 100644
--- a/webui/src/components/settings/SettingsPage.tsx
+++ b/webui/src/components/settings/SettingsPage.tsx
@@ -270,15 +270,6 @@ export function SettingsPage({
return <AboutSettings settings={settings} />;
case "notifications":
return <NotificationSettings localPrefs={localPrefs} onChangeLocalPrefs={setLocalPrefs} />;
- case "appearance":
- return (
- <AppearanceSettings
- themePreference={themePreference}
- onChangeTheme={onChangeTheme}
- localPrefs={localPrefs}
- onChangeLocalPrefs={setLocalPrefs}
- />
- );
case "models":
return (
<div className="settings-stack">
@@ -494,6 +485,9 @@ export function SettingsPage({
const renderSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
switch (section) {
+ case "appearance":
+ return <AppearanceSettings themePreference={themePreference} onChangeTheme={onChangeTheme}
+ localPrefs={localPrefs} onChangeLocalPrefs={setLocalPrefs} />;
case "channels":
return (
<ChannelsSettings
@@ -623,7 +617,9 @@ export function SettingsPage({
return renderSettingsSection(section, embedded);
}
};
- const sectionReady = settings !== null || activeSection === "skills" || activeSection === "apps"
+ // Appearance reads only browser-local preferences, not the gateway settings snapshot.
+ const localSection = activeSection === "appearance";
+ const sectionReady = localSection || settings !== null || activeSection === "skills" || activeSection === "apps"
|| activeSection === "channels" || activeSection === "automations";
return (
@@ -790,7 +786,7 @@ export function SettingsPage({
"flex min-h-0 flex-1 flex-col xl:overflow-hidden",
)}
>
- {error ? (
+ {error && (!localSection || settings !== null) ? (
<div className="rounded-floating border border-destructive/20 bg-destructive/5 px-4 py-3 text-[13px] text-destructive">
{error}
</div>
diff --git a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
index d5023f206..4d733bda5 100644
--- a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
+++ b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
@@ -8,7 +8,7 @@ import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
import { cn } from "@/lib/utils";
-type Control = "switch" | "input" | "duration" | "idle-timeout" | "segments" | "reading" | "theme" | "edit" | "text" | "feature";
+type Control = "switch" | "input" | "duration" | "idle-timeout" | "segments" | "edit" | "text" | "feature";
const block = "rounded bg-muted-foreground/20";
function Title({ heading = false }: { heading?: boolean }) {
@@ -25,11 +25,9 @@ function Row({ control }: { control: Control }) {
{control === "feature" ? <div className={cn(block, "mr-3 h-3 w-14")} /> : null}
{control === "idle-timeout" ? <div className="flex items-center gap-2">
<div className={cn(block, "h-9 w-28 rounded-full")} /><div className={cn(block, "h-3 w-10")} />
- </div> : control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} data-skeleton-reading-size={control === "reading" ? "" : undefined} className={cn(block,
+ </div> : control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} className={cn(block,
toggle ? "h-5 w-9 shrink-0 rounded-full" : control === "input" ? "h-9 w-full rounded-full"
- : control === "segments" || control === "reading" || control === "theme" ? "segmented-control w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[1lh] w-24 text-ui",
- (control === "segments" || control === "reading") && "h-[34px]", control === "theme" && "h-8",
- control === "reading" && "w-36 [@media(pointer:coarse)]:w-40",
+ : control === "segments" ? "segmented-control h-[34px] w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[1lh] w-24 text-ui",
)} />}
</div>
</div>;
@@ -71,9 +69,6 @@ export function SettingsSectionSkeleton({ section, showRestart = false }: { sect
{[0, 1, 2, 3].map((index) => <SettingsGroup key={index}><Row control={index === 3 ? "switch" : "feature"} /></SettingsGroup>)}
</>;
else switch (section) {
- case "appearance":
- content = <><Group controls={["theme", "input"]} /><Group controls={["reading", "segments", "segments", "switch", "switch"]} /></>;
- break;
case "notifications":
content = <section><Title /><SettingsGroup>
<Row control="switch" />
diff --git a/webui/src/tests/settings-overview.test.tsx b/webui/src/tests/settings-overview.test.tsx
index 9d18d66a8..11f9e8dab 100644
--- a/webui/src/tests/settings-overview.test.tsx
+++ b/webui/src/tests/settings-overview.test.tsx
@@ -170,6 +170,37 @@ describe("Settings overview and appearance", () => {
expect(url.href).not.toContain("private-host");
});
+ it("edits browser appearance while gateway settings are pending or unavailable", async () => {
+ let rejectSettings!: (reason: Error) => void;
+ const pendingSettings = new Promise<Response>((_, reject) => { rejectSettings = reject; });
+ vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => String(input) === "/api/settings"
+ ? pendingSettings : new Promise<Response>(() => {})));
+ renderSettingsView({ initialSection: "appearance", initialSettings: null, showSidebar: true });
+ const input = screen.getByRole("spinbutton", { name: "Custom text size" });
+ fireEvent.focus(input);
+ fireEvent.change(input, { target: { value: "22" } });
+ await waitFor(() => expect(readLocalPreferences().customReadingTextSize).toBe(22));
+ await act(async () => { rejectSettings(new Error("Gateway unavailable")); });
+ expect(screen.getByRole("spinbutton", { name: "Custom text size" })).toBe(input);
+ fireEvent.change(input, { target: { value: "24" } });
+ await waitFor(() => expect(readLocalPreferences().customReadingTextSize).toBe(24));
+ expect(screen.queryByText("Gateway unavailable")).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "Models" }));
+ expect(await screen.findByText("Gateway unavailable")).toBeVisible();
+ });
+
+ it("keeps an explicit native restart failure visible on Appearance", async () => {
+ vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>(() => {})));
+ const restart = vi.fn().mockRejectedValue(new Error("Engine restart failed"));
+ renderSettingsView({ initialSection: "appearance", showSidebar: true,
+ initialSettings: { ...settingsPayload(), surface: "native", runtime_capabilities: { can_restart_engine: true, can_open_logs: false, can_export_diagnostics: false } },
+ onNativeEngineRestart: restart });
+ fireEvent.click(screen.getByRole("button", { name: "Restart" }));
+ expect(await screen.findByText("Engine restart failed")).toBeVisible();
+ expect(restart).toHaveBeenCalledTimes(1);
+ expect(screen.getByRole("spinbutton", { name: "Custom text size" })).toBeEnabled();
+ });
+
it("saves the reading size immediately while preserving the other local preferences", async () => {
const previous = { ...DEFAULT_LOCAL_PREFS, codeWrap: false, brandLogos: false, notificationSound: true };
writeLocalPreferences(previous);