[0]) => { void setAppLanguage(next).then(() => setLanguage(next)); };
+ return
+
+
+
;
+}
+
+function SkeletonSurface() {
+ const params = new URLSearchParams(location.search);
+ const surface = params.get("surface") ?? "chats";
+ const state = params.get("state") ?? "loaded";
+ const section = (params.get("section") ?? "appearance") as SettingsSectionKey;
+ const density = params.has("compact") ? "compact" : "comfortable";
+ const dark = params.has("dark");
+ useLayoutEffect(() => { document.documentElement.classList.toggle("dark", dark); }, [dark]);
+ const controller = useSettingsController({ initialSection: section, initialSettings: previewSettings, onModelNameChange: noop });
+ detailState = state;
+ const loading = state === "loading" || state === "refresh";
+ const empty = state === "loading" || state === "error";
+ return
+ {surface === "settings" ?
+ :
+ {surface === "chats" ? {}} />
+ : surface === "automations" ?
+ : surface === "skill-detail" ?
+ : surface === "session-jobs" ? jobs} onEdit={async () => jobs} />
+ : surface === "linear-members" ? : null}
+ }
+
;
+}
diff --git a/webui/browser/skeleton-additions.spec.ts b/webui/browser/skeleton-additions.spec.ts
new file mode 100644
index 000000000..d681fb0f0
--- /dev/null
+++ b/webui/browser/skeleton-additions.spec.ts
@@ -0,0 +1,149 @@
+import { expect, test, type Locator, type Page } from "@playwright/test";
+
+const fixture = (surface: string, state = "loaded", extra = "") => `/browser/fixture.html?case=skeleton-additions&surface=${surface}&state=${state}${extra}`;
+const status = (page: Page) => page.locator('[role="status"][aria-busy="true"]');
+
+async function settle(page: Page) {
+ await page.evaluate(async () => {
+ await document.fonts.ready;
+ await Promise.all(document.getAnimations().filter((animation) => animation.effect?.getTiming().iterations !== Infinity)
+ .map((animation) => animation.finished.catch(() => {})));
+ });
+}
+
+async function boxes(locator: Locator) {
+ await expect(locator.first()).toBeVisible();
+ return locator.evaluateAll((elements) => elements.map((element) => {
+ const { x, y, width, height } = element.getBoundingClientRect();
+ return { x, y, width, height };
+ }));
+}
+
+function sameBoxes(actual: Awaited>, expected: typeof actual) {
+ expect(actual).toHaveLength(expected.length);
+ for (let index = 0; index < actual.length; index++) for (const key of ["x", "y", "width", "height"] as const) {
+ expect(Math.abs(actual[index][key] - expected[index][key]), `row ${index} ${key}`).toBeLessThan(0.5);
+ }
+}
+
+async function accessibleSkeleton(page: Page) {
+ await expect(status(page).first()).toBeVisible();
+ expect(await status(page).first().getAttribute("aria-label")).toBeTruthy();
+ await expect(status(page).first().locator(".animate-pulse")).toHaveAttribute("aria-hidden", "true");
+ expect(await status(page).first().locator(".animate-pulse").evaluate((element) => getComputedStyle(element).animationName)).toBe("none");
+ expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
+}
+
+for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
+ test.describe(`${width}px ${locale} new first-load skeletons`, () => {
+ test.use({ viewport: { width, height: 1000 }, reducedMotion: "reduce", hasTouch: width === 390 });
+ test.beforeEach(async ({ page }) => {
+ await page.addInitScript((language) => localStorage.setItem("nanobot.locale", language), locale);
+ await page.clock.setFixedTime(new Date("2026-10-19T12:00:00Z"));
+ });
+
+ test("sidebar rows preserve comfortable, compact and touch density", async ({ page }) => {
+ for (const extra of ["", "&compact"]) {
+ await page.goto(fixture("chats", "loaded", extra));
+ await settle(page);
+ const loaded = await boxes(page.locator("[data-chat-row]"));
+ await page.goto(fixture("chats", "loading", extra));
+ await settle(page);
+ sameBoxes((await boxes(page.locator("[data-chat-skeleton-row]"))).slice(0, loaded.length), loaded);
+ await accessibleSkeleton(page);
+ }
+ });
+
+ test("settings sections preserve their loaded row layout", async ({ page }) => {
+ for (const section of ["appearance", "capabilities", "runtime", "advanced", "overview", "models", "about"]) {
+ await page.goto(fixture("settings", "loaded", `§ion=${section}`));
+ if (section === "runtime") await expect(page.locator('[data-settings-section] button').filter({ hasText: locale === "en" ? "Start API server" : "启动 API 服务" })).toBeVisible();
+ await settle(page);
+ const target = page.locator("[data-settings-section]");
+ const selector = section === "overview" ? "section button.group" : section === "models" ? '[data-testid^="model-call-order-row"], .settings-footer' : section === "about" ? ".settings-list-row" : ".settings-row";
+ const loaded = await boxes(target.locator(selector));
+ await page.goto(fixture("settings", "loading", `§ion=${section}`));
+ 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]";
+ sameBoxes(await boxes(target.locator(skeletonSelector)), loaded);
+ await accessibleSkeleton(page);
+ }
+ });
+
+ 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) => {
+ await page.goto(fixture("automations", state));
+ if (nextMonth) await page.getByRole("button", { name: locale === "en" ? "Next month" : "下个月" }).click();
+ await settle(page);
+ };
+ await open("loaded");
+ const toolbar = await boxes(page.locator(".automation-panel-toolbar"));
+ const nav = await boxes(page.locator(".automation-calendar-navigation"));
+ const grid = width === 1440 ? await boxes(page.locator(".automation-calendar-day")) : null;
+ if (grid) expect(grid).toHaveLength(nextMonth ? 42 : 35);
+ const agenda = !nextMonth && width === 390 ? await boxes(page.locator(".automation-calendar-agenda li")) : null;
+ await open("loading");
+ sameBoxes(await boxes(page.locator(".automation-panel-toolbar")), toolbar);
+ sameBoxes(await boxes(page.locator(".automation-calendar-navigation")), nav);
+ if (grid) sameBoxes(await boxes(page.locator(".automation-calendar-day")), grid);
+ if (agenda) sameBoxes(await boxes(page.locator("[data-agenda-skeleton-row]")), agenda);
+ await accessibleSkeleton(page);
+ }
+ await page.goto(fixture("automations"));
+ await page.locator(".automation-view-switch button").first().click();
+ await settle(page);
+ const rows = await boxes(page.locator('section[aria-label] button[aria-haspopup="dialog"]'));
+ await page.goto(fixture("automations", "loading"));
+ await page.locator(".automation-view-switch button").first().click();
+ await settle(page);
+ sameBoxes(await boxes(page.locator("[data-automation-task-skeleton]")), rows);
+ });
+
+ test("skill detail keeps the known summary and matches the toggle and instructions disclosure", async ({ page }) => {
+ const open = async (state: string) => {
+ await page.goto(fixture("skill-detail", state));
+ await page.getByRole("button", { name: locale === "en" ? "Open details for project-review" : "查看 project-review 详情" }).click();
+ await settle(page);
+ };
+ await open("loaded");
+ await expect(page.getByRole("dialog").getByRole("switch")).toBeEnabled();
+ const toggle = await boxes(page.getByRole("dialog").getByRole("switch").locator(".."));
+ const instructions = await boxes(page.getByRole("dialog").getByRole("button", { name: /SKILL.md/ }).locator(".."));
+ const title = await boxes(page.getByRole("dialog").getByRole("heading", { name: "project-review" }));
+ await open("loading");
+ await expect(page.getByRole("dialog").getByText("Review the repository and summarize actionable changes.")).toBeVisible();
+ sameBoxes(await boxes(page.locator("[data-skill-toggle-skeleton]")), toggle);
+ sameBoxes(await boxes(page.locator("[data-skill-instructions-skeleton]")), instructions);
+ sameBoxes(await boxes(page.getByRole("dialog").getByRole("heading", { name: "project-review" })), title);
+ await accessibleSkeleton(page);
+ });
+
+ test("session automation and Linear members keep row and action alignment", async ({ page }) => {
+ for (const surface of ["session-jobs", "linear-members"]) {
+ const open = async (state: string) => {
+ await page.goto(fixture(surface, state));
+ if (surface === "session-jobs") await page.getByRole("button", { name: locale === "en" ? "Session details" : "会话详情" }).click();
+ else await page.locator("button[aria-expanded]").first().click();
+ await settle(page);
+ };
+ await open("loaded");
+ const rows = await boxes(surface === "session-jobs" ? page.getByRole("dialog").locator('button[aria-haspopup="dialog"]') : page.locator(".settings-row"));
+ await open("loading");
+ sameBoxes(await boxes(page.locator(surface === "session-jobs" ? "[data-session-job-skeleton]" : "[data-member-skeleton-row]")), rows);
+ await accessibleSkeleton(page);
+ }
+ });
+
+ test("cached settings and lists stay visible during background refresh", async ({ page }) => {
+ for (const surface of ["settings", "chats", "automations", "session-jobs", "linear-members"]) {
+ await page.goto(fixture(surface, "refresh"));
+ if (surface === "session-jobs") await page.getByRole("button", { name: locale === "en" ? "Session details" : "会话详情" }).click();
+ if (surface === "linear-members") await page.locator("button[aria-expanded]").first().click();
+ await settle(page);
+ await expect(status(page)).toHaveCount(0);
+ await expect(surface === "settings" || surface === "linear-members" ? page.getByRole("switch").first() : page.getByText("Project summary", { exact: true }).first()).toBeVisible();
+ }
+ });
+ });
+}
diff --git a/webui/browser/skeleton-fixture.tsx b/webui/browser/skeleton-fixture.tsx
new file mode 100644
index 000000000..93ad032d6
--- /dev/null
+++ b/webui/browser/skeleton-fixture.tsx
@@ -0,0 +1,78 @@
+import { useState } from "react";
+
+import { FilePreviewPanelView } from "@/components/FilePreviewPanelView";
+import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings";
+import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
+import { ModelIdPicker } from "@/components/settings/shared/ModelControls";
+import { AppsCatalogSettings, DEFAULT_CUSTOM_MCP_FORM } from "@/components/settings/system/AppsSettings";
+import { ChannelsSettings } from "@/components/settings/system/ChannelsSettings";
+import { McpManagementDialog } from "@/components/settings/system/McpManagementDialog";
+import { WorkspaceProjectPicker } from "@/components/thread/WorkspaceControls";
+import { settings } from "@/dev/gallery/settings";
+import { fetchWorkspaceDirectories } from "@/lib/api";
+import type { McpPresetInfo, NanobotFeatureInfo } from "@/lib/types";
+
+const noop = () => {};
+const names = ["Search documentation", "Read repository", "List projects", "Inspect changes", "Review results", "Write notes"];
+const preset: McpPresetInfo = {
+ name: "docs", display_name: "Docs MCP", category: "Workflow", description: "Search the team knowledge base.",
+ docs_url: "", requires: "", note: "", connection_summary: "https://example.com/mcp",
+ transport: "streamableHttp", install_supported: true, installed: true, configured: true,
+ available: true, status: "configured", required_fields: [], source: "custom",
+};
+
+export function SkeletonFixture({ surface, loading }: { surface: string; loading: boolean }) {
+ const [model, setModel] = useState("");
+ const [previewLoading, setPreviewLoading] = useState(loading);
+ const feature: NanobotFeatureInfo = {
+ name: "telegram", display_name: "Telegram", type: "channel", enabled: true, installed: true,
+ configured: true, ready: true, install_supported: true, status: "enabled", requires_restart: false,
+ };
+ return
+ {surface === "workspace" ? fetchWorkspaceDirectories("fixture", path, query, showHidden, allowPartial)}
+ onChange={noop} /> : surface === "apps" || surface === "cli" ? ({
+ name: `app-${index}`, display_name: name, category: "Tools", description: "Search and inspect the project.",
+ requires: "", source: "builtin", entry_point: `app-${index}`, install_supported: true, installed: false,
+ available: false, status: "not_installed", skill_installed: false,
+ })) : [], installed_count: 0 }}
+ mcpPresets={loading ? null : { presets: names.map((name, index) => ({ ...preset, name: `docs-${index}`, display_name: name })), installed_count: 6 }}
+ cliAppsLoading={loading} mcpPresetsLoading={loading} query="" filter={surface === "cli" ? "cli" : "mcp"}
+ cliActionKey={null} mcpActionKey={null} mcpOAuthFlow={null} mcpOAuthPopupBlocked={false}
+ mcpOAuthCallbackUrl="" mcpOAuthCompleting={false} mcpOAuthCallbackError={null}
+ cliMessage={null} cliError={null} cliFocusName={null} mcpMessage={null} mcpError={null}
+ mcpFieldValues={{}} customMcpForm={DEFAULT_CUSTOM_MCP_FORM} mcpConfigImport=""
+ showBrandLogos={false} requiresRestartPending={false}
+ onQueryChange={noop} onFilterChange={noop} onCliAction={noop} onMcpAction={noop}
+ onMcpOAuthConnect={noop} onMcpOAuthCancel={noop} onMcpOAuthOpen={noop}
+ onMcpOAuthCallbackUrlChange={noop} onMcpOAuthComplete={noop} onDismissStatus={noop}
+ onBackToChat={noop} onMcpFieldChange={noop} onCustomMcpFormChange={noop}
+ onMcpConfigImportChange={noop} onSaveCustomMcp={noop} onImportMcpConfig={noop} onMcpToolsChange={noop}
+ /> : surface === "channels" ? ({ ...feature, name: `channel-${index}`, display_name: name })), enabled_count: 6, requires_restart: false }}
+ loading={loading} actionKey={null} showBrandLogos={false} error={null} requiresRestartPending={false}
+ onAction={noop} onFeaturesUpdate={noop} onDismissStatus={noop}
+ /> : surface === "skills" ? ({
+ name, description: "Search, inspect and maintain the project.", source: "builtin", available: true, enabled: true,
+ }))} /> : surface === "marketplace" ?
+ : surface === "models" || surface === "models-compact" ? provider.name === "openai" ? { ...provider, model_catalog: "official" } : provider) }}
+ provider={surface === "models-compact" ? "openai" : "anthropic"}
+ value={model} showProviderLogos={false} onChange={setModel} />
+ : surface === "tools" ? `read_project_${index}`), tool_count: loading ? 0 : 6 }}
+ values={{}} actionKey={loading ? "test:docs" : null} statusLabel="Connected" statusTone="success" tab="tools"
+ icon={DM} onTabChange={noop} onOpenChange={noop} onFieldChange={noop}
+ onAction={noop} onOAuthConnect={noop} onToolsChange={noop}
+ /> : surface === "file" || surface === "markdown" ? `value_${index} = ${JSON.stringify(name)}`).join("\n"),
+ } }} imageOpen={false} onImageOpenChange={noop} onImageError={noop} />
: null}
+ {surface === "file" || surface === "markdown" ? : null}
+ ;
+}
diff --git a/webui/browser/skeleton-layout.spec.ts b/webui/browser/skeleton-layout.spec.ts
new file mode 100644
index 000000000..d3fda637f
--- /dev/null
+++ b/webui/browser/skeleton-layout.spec.ts
@@ -0,0 +1,220 @@
+import { expect, test, type Locator, type Page } from "@playwright/test";
+
+const fixture = (surface: string, loading = false) => `/browser/fixture.html?case=skeleton&surface=${surface}${loading ? "&loading" : ""}`;
+const status = (page: Page) => page.locator('[role="status"][aria-busy="true"]');
+const catalogRows = {
+ channels: [".settings-list-row", ".settings-list-row"],
+ apps: ["article > .group", ".px-3.py-3"],
+ cli: [".apps-catalog-row", ".px-3.py-3"],
+ skills: ["button:has(h3)", ".px-2.py-3"],
+};
+
+async function settle(page: Page) {
+ await page.evaluate(async () => {
+ await document.fonts.ready;
+ await Promise.all(document.getAnimations()
+ .filter((animation) => animation.effect?.getTiming().iterations !== Infinity)
+ .map((animation) => animation.finished.catch(() => {})));
+ });
+}
+
+async function box(locator: Locator) {
+ await expect(locator).toBeVisible();
+ return (await locator.boundingBox())!;
+}
+
+function sameBox(actual: { x: number; y: number; width: number; height: number }, expected: typeof actual) {
+ for (const key of ["x", "y", "width", "height"] as const) {
+ expect(Math.abs(actual[key] - expected[key]), key).toBeLessThan(0.5);
+ }
+}
+
+async function noOverflow(page: Page) {
+ expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
+}
+
+const marketplaceSkills = ["skills_sh", "skillhub"].flatMap((provider) => Array.from({ length: 5 }, (_, index) => ({
+ id: `${provider}:project-${index}`, skill_id: `project-${index}`, name: `Project Skill ${index + 1}`,
+ source: "team/project-skills", provider, installs: 200, url: "https://example.com/skill",
+ installed: false, install_supported: true, metric: "installs_total", rank: index + 1,
+})));
+
+for (const width of [390, 1440]) {
+ for (const locale of ["en", "zh-CN"]) {
+ test.describe(`${width}px ${locale}`, () => {
+ test.use({ viewport: { width, height: 900 }, reducedMotion: "reduce", hasTouch: width === 390 });
+ test.beforeEach(async ({ page }) => {
+ await page.addInitScript((language) => localStorage.setItem("nanobot.locale", language), locale);
+ });
+
+ test("catalog skeletons preserve loaded row, icon, title and action geometry", async ({ page }) => {
+ for (const [surface, [loadedSelector, loadingSelector]] of Object.entries(catalogRows)) {
+ await page.goto(fixture(surface));
+ const loaded = page.locator(loadedSelector).first();
+ const row = await box(loaded);
+ const icon = await box(surface === "channels" ? loaded.locator('[data-testid^="channel-logo"]') : loaded.locator(":scope > :first-child"));
+ const title = await box(loaded.locator("h3"));
+ const action = width === 1440 || surface !== "skills" ? await box(loaded.locator(":scope > :last-child")) : null;
+ await page.goto(fixture(surface, true));
+ const skeleton = status(page).locator(loadingSelector).first();
+ sameBox(await box(skeleton), row);
+ sameBox(await box(skeleton.locator(":scope > :first-child")), icon);
+ const placeholder = await box(skeleton.locator(":scope > :nth-child(2) [class*='bg-muted-foreground']").first());
+ expect(placeholder.x).toBe(title.x);
+ expect(placeholder.y + placeholder.height / 2).toBe(title.y + title.height / 2);
+ if (action) sameBox(await box(skeleton.locator(":scope > :last-child")), action);
+ await noOverflow(page);
+ }
+ });
+
+ test("marketplace skeletons preserve groups, ranks and provider-specific trend columns", async ({ page }) => {
+ let release = () => {};
+ let pending: Promise | undefined;
+ await page.route("**/api/webui/skills/trending?**", async (route) => {
+ await pending;
+ await route.fulfill({ json: { period: "mixed", provider: "all", install_supported: true, skills: marketplaceSkills } });
+ });
+ await page.route("**/api/webui/skills/search?**", async (route) => {
+ await pending;
+ await route.fulfill({ json: { query: "project", provider: "all", install_supported: true,
+ skills: marketplaceSkills.map((skill) => ({ ...skill, rank: undefined })) } });
+ });
+ await page.route("**/api/webui/skills/trends?**", (route) => route.fulfill({ json: { trends: {} } }));
+ for (const view of ["grouped", "single", "search"]) {
+ const open = async () => {
+ await page.goto(fixture("marketplace"));
+ if (view === "single") await page.getByRole("tab", { name: "skills.sh", exact: true }).click();
+ if (view === "search") await page.locator("input").fill("project");
+ };
+ await open();
+ const loaded = page.locator(".group.py-3\\.5");
+ await expect(loaded).toHaveCount(view === "single" ? 5 : 10);
+ const rows = await loaded.evaluateAll((elements) => elements.map((element) => {
+ const r = element.getBoundingClientRect();
+ const text = element.querySelector("h3")!.parentElement!.parentElement!.getBoundingClientRect();
+ return { row: { x: r.x, y: r.y, width: r.width, height: r.height }, text: { x: text.x, width: text.width } };
+ }));
+ pending = new Promise((resolve) => { release = resolve; });
+ try {
+ await open();
+ const skeletons = status(page).locator(".py-3\\.5");
+ await expect(skeletons).toHaveCount(rows.length);
+ for (let index = 0; index < rows.length; index++) {
+ sameBox(await box(skeletons.nth(index)), rows[index].row);
+ const text = await box(skeletons.nth(index).locator(".flex-1"));
+ expect(text.x).toBe(rows[index].text.x);
+ expect(text.width).toBe(rows[index].text.width);
+ }
+ await noOverflow(page);
+ } finally { release(); pending = undefined; }
+ await page.goto("about:blank");
+ }
+ });
+
+ test("model catalog skeletons follow single-line official and two-line managed options", async ({ page }) => {
+ let release = () => {};
+ let pending: Promise | undefined;
+ await page.route("**/api/settings/provider-models?**", async (route) => {
+ await pending;
+ const provider = new URL(route.request().url()).searchParams.get("provider");
+ await route.fulfill({ json: { provider, status: "available", source: "api", catalog_kind: "live",
+ models: [0, 1, 2].map((index) => ({ id: `project-${index}`,
+ ...(provider === "anthropic" ? { label: `Project ${index}`, description: "Code assistance" } : {}) })) } });
+ });
+ for (const surface of ["models", "models-compact"]) {
+ await page.goto(fixture(surface));
+ await page.getByRole("combobox").click();
+ const loaded = page.getByRole("option").first();
+ await expect(loaded).toBeVisible();
+ await settle(page);
+ const row = await box(loaded);
+ const icon = await box(loaded.locator(":scope > :first-child > :first-child"));
+ pending = new Promise((resolve) => { release = resolve; });
+ try {
+ await page.goto(fixture(surface));
+ await page.getByRole("combobox").click();
+ await expect(status(page)).toBeVisible();
+ await settle(page);
+ const skeleton = status(page).locator(".px-2.py-1\\.5").first();
+ sameBox(await box(skeleton), row);
+ sameBox(await box(skeleton.locator(":scope > :first-child")), icon);
+ await noOverflow(page);
+ } finally { release(); pending = undefined; }
+ await page.goto("about:blank");
+ }
+ });
+
+ test("MCP tools preserve the localized toolbar and checkbox rows", async ({ page }) => {
+ await page.goto(fixture("tools"));
+ const loaded = page.getByRole("tabpanel");
+ await expect(loaded.getByRole("checkbox")).toHaveCount(6);
+ await settle(page);
+ const row = await box(loaded.locator("label:has(input[type=checkbox])").first());
+ const search = await box(loaded.locator("input:not([type=checkbox])"));
+ await page.goto(fixture("tools", true));
+ await expect(status(page)).toBeVisible();
+ await settle(page);
+ sameBox(await box(status(page).locator(".min-h-11").first()), row);
+ sameBox(await box(status(page).locator("[aria-hidden] > .flex > :first-child")), search);
+ await noOverflow(page);
+ });
+
+ test("directory loading preserves the centered whole-row viewport and scrollbar gutter", async ({ page }) => {
+ let release = () => {};
+ let blocked = false;
+ const pending = new Promise((resolve) => { release = resolve; });
+ await page.route("**/api/workspaces/directories?**", async (route) => {
+ if (blocked) await pending;
+ const directory = new URL(route.request().url()).searchParams.get("path")!;
+ await route.fulfill({ json: { path: directory, parent: "/srv", host: "dev-server", platform: "Linux", truncated: false,
+ entries: Array.from({ length: 30 }, (_, index) => ({ name: `project-${index}`, path: `${directory}/project-${index}` })) } });
+ });
+ const open = async () => {
+ await page.goto(fixture("workspace"));
+ await page.getByTestId("skeleton-fixture").getByRole("button").first().click();
+ };
+ await open();
+ await expect(page.getByRole("option").first()).toBeVisible();
+ await settle(page);
+ const row = await box(page.getByRole("option").first());
+ blocked = true;
+ try {
+ await open();
+ await expect(page.locator(".workspace-directory-loading")).toBeVisible();
+ await settle(page);
+ sameBox(await box(page.locator(".workspace-directory-loading [aria-hidden] > div").first()), row);
+ await noOverflow(page);
+ } finally { release(); }
+ });
+
+ test("file preview skeletons follow code gutters and Markdown controls", async ({ page }) => {
+ await page.goto(fixture("file"));
+ await expect(page.getByTestId("viewport-code-rows")).toBeVisible();
+ const source = await box(page.locator("pre"));
+ const code = await box(page.locator("[data-highlighted]"));
+ await page.goto(fixture("file", true));
+ sameBox(await box(status(page).locator(".font-mono")), source);
+ const line = await box(status(page).locator(".font-mono > div > :last-child").first());
+ expect(line.x).toBe(code.x);
+ await noOverflow(page);
+ await page.goto(fixture("markdown"));
+ const heading = await box(page.getByRole("heading", { name: "Project overview" }));
+ const controls = await box(page.getByTestId("file-preview-panel").locator(":scope > div").first());
+ await page.goto(fixture("markdown", true));
+ sameBox(await box(status(page).locator("[aria-hidden] > .flex").first()), controls);
+ const title = await box(status(page).locator(".h-7 > div"));
+ expect(title.x).toBe(heading.x);
+ expect(title.y + title.height / 2).toBe(heading.y + heading.height / 2);
+ await noOverflow(page);
+ await page.goto(fixture("markdown"));
+ await expect(page.getByRole("heading", { name: "Project overview" })).toBeVisible();
+ await page.getByTestId("file-preview-panel").locator(".segmented-control button").nth(1).click();
+ await expect(page.getByTestId("viewport-code-rows")).toBeVisible();
+ const markdownSource = await box(page.locator("pre"));
+ await page.getByTestId("reload-preview").click();
+ const markdownLoading = await box(status(page).locator(".font-mono"));
+ for (const key of ["x", "y", "width"] as const) expect(markdownLoading[key]).toBe(markdownSource[key]);
+ });
+ });
+ }
+}
diff --git a/webui/browser/startup-shell.spec.ts b/webui/browser/startup-shell.spec.ts
new file mode 100644
index 000000000..8de56f620
--- /dev/null
+++ b/webui/browser/startup-shell.spec.ts
@@ -0,0 +1,47 @@
+import { expect, test } from "@playwright/test";
+
+for (const width of [412, 1440]) {
+ test.describe(`${width}px document startup skeleton`, () => {
+ test.use({ viewport: { width, height: 922 }, reducedMotion: "reduce" });
+ for (const surface of ["skills", "apps", "channels", "automations", "settings", "chat"]) {
+ test(`${surface} paints before the application and stylesheet download`, async ({ page }) => {
+ await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
+ // Neither React nor the app stylesheet may supply this first paint.
+ await page.route(/\/(?:src\/main\.tsx|assets\/index-[^/]+\.(?:js|css))$/, (route) => route.abort());
+ await page.goto(`/#/${surface === "chat" ? "chat/websocket%3Aexample" : surface}`, { waitUntil: "domcontentloaded" });
+ const shell = page.locator(".startup-shell");
+ await expect(shell).toHaveAttribute("data-startup-surface", surface);
+ await expect(shell).toHaveAttribute("aria-busy", "true");
+ await expect(shell.locator(surface === "chat" ? ".startup-composer" : ".startup-page")).toBeVisible();
+ const blocks = shell.locator(".startup-block:visible");
+ expect(await blocks.count()).toBeGreaterThan(5);
+ const box = await blocks.first().boundingBox();
+ expect(box!.width).toBeGreaterThan(0);
+ expect(box!.height).toBeGreaterThan(0);
+ expect(await blocks.first().evaluate((element) => getComputedStyle(element).backgroundColor)).not.toBe("rgba(0, 0, 0, 0)");
+ expect(await shell.getByRole("button").count()).toBe(0);
+ expect(await shell.getByRole("textbox").count()).toBe(0);
+ expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
+ const status = shell.getByRole("status");
+ await expect(status).toHaveText("Loading nanobot…");
+ expect(await status.evaluate((element) => element.getBoundingClientRect().width)).toBe(1);
+ });
+ }
+
+ test("restores a collapsed sidebar and the settings-section alias before React", async ({ page }) => {
+ await page.addInitScript(() => {
+ localStorage.setItem("nanobot-webui.sidebar", "0");
+ localStorage.setItem("nanobot-webui.theme", "dark");
+ localStorage.setItem("nanobot.locale", "zh-CN");
+ });
+ await page.route("**/src/main.tsx", (route) => route.abort());
+ await page.goto("/#/settings?section=skills");
+ const shell = page.locator(".startup-shell");
+ await expect(shell).toHaveAttribute("data-startup-surface", "skills");
+ await expect(shell).toHaveAttribute("data-sidebar-expanded", "false");
+ await expect(shell.getByRole("status")).toHaveText("正在加载 nanobot…");
+ await expect(page.locator("html")).toHaveClass(/dark/);
+ if (width === 1440) expect((await shell.locator(".startup-navigation").boundingBox())!.width).toBe(56);
+ });
+ });
+}
diff --git a/webui/index.html b/webui/index.html
index 753715d89..9e1b91d59 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -77,22 +77,8 @@
}
}
- .startup-shell { position: relative; height: 100%; }
- .startup-header { display: flex; justify-content: space-between; padding: 5px 13px; }
- .startup-control-shadow {
- width: 28px; height: 28px; border-radius: 8px; background: rgba(0,0,0,0.025);
- }
- .startup-composer {
- position: absolute; inset-inline: 16px; bottom: max(24px, env(safe-area-inset-bottom));
- box-sizing: border-box; max-width: 768px; margin-inline: auto;
- height: 96px; border-radius: 24px; background: rgba(0,0,0,0.025);
- }
- .startup-status {
- position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
- overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
- }
- html.dark :is(.startup-control-shadow, .startup-composer) { background: rgba(255,255,255,0.035); }
+
`)
+ .replace(/ {
const hmrPath = "/__nanobot_vite_hmr";
return {
- plugins: [react(), componentGallery(path.resolve(__dirname, "..")), guardWebuiEntryChunk(), gzipWebuiAssets()],
+ plugins: [react(), startupSkeleton(), componentGallery(path.resolve(__dirname, "..")), guardWebuiEntryChunk(), gzipWebuiAssets()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),