diff --git a/nanobot/channels/linear/webui/LinearMemberAccessView.tsx b/nanobot/channels/linear/webui/LinearMemberAccessView.tsx index 3652d196b..7ce98790b 100644 --- a/nanobot/channels/linear/webui/LinearMemberAccessView.tsx +++ b/nanobot/channels/linear/webui/LinearMemberAccessView.tsx @@ -6,6 +6,7 @@ import { channelTranslator } from "@/channel-plugins/i18n"; import { ToggleButton } from "@/components/ui/toggle-button"; import { SETTINGS_SEARCH_INPUT_CLASS, SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls"; import { SettingsHint } from "@/components/settings/shared/SettingsHint"; +import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus"; import { Button } from "@/components/ui/button"; import { DisclosureContent } from "@/components/ui/disclosure"; import { SearchInput } from "@/components/ui/input"; @@ -102,7 +103,15 @@ export function LinearMemberAccessView({ snapshot, disabled = false, onLoad, onS {payload && !error && visible.length === 0 ?

{tx("members.empty", "No matching active members.")}

: null} - + {expanded && loading && !payload ? + {[0, 1, 2].map((index) =>
+
+
+
+
+
+
)} + :
    {visible.map((member) => { const save = saves[member.id]; @@ -135,7 +144,7 @@ export function LinearMemberAccessView({ snapshot, disabled = false, onLoad, onS ; })}
-
+ } ); diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index ffa30e12f..fd7980542 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -17,6 +17,9 @@ import { Button } from "@/components/ui/button"; import { SettingsIcon } from "@/components/icons/product-icons"; import { initializeI18n } from "@/i18n"; import type { McpPresetInfo, UIMessage } from "@/lib/types"; +import { SkeletonFixture } from "./skeleton-fixture"; +import { installSkeletonPreviewApi, SkeletonAdditionsFixture } from "./skeleton-additions-fixture"; +import { NewChatSkeletonFixture } from "./new-chat-skeleton-fixture"; import "../src/globals.css"; const history: UIMessage[] = [ @@ -136,9 +139,16 @@ function AppsFixture() { onMcpToolsChange={noop} />; } +if (parameters.get("case") === "skeleton-additions") installSkeletonPreviewApi(); await initializeI18n(); createRoot(document.getElementById("root")!).render( - {parameters.get("case") === "apps" + {parameters.get("case") === "new-chat-skeleton" + ? + : parameters.get("case") === "skeleton-additions" + ? + : parameters.get("case") === "skeleton" + ? + : parameters.get("case") === "apps" ? : parameters.get("case") === "rail" ? diff --git a/webui/browser/new-chat-skeleton-fixture.tsx b/webui/browser/new-chat-skeleton-fixture.tsx new file mode 100644 index 000000000..1186d1cfa --- /dev/null +++ b/webui/browser/new-chat-skeleton-fixture.tsx @@ -0,0 +1,26 @@ +import { ThreadShell } from "@/components/thread/ThreadShell"; +import { StartupSkeleton } from "@/components/StartupSkeleton"; +import { settings } from "@/dev/gallery/settings"; +import "@/components/startup-skeleton.css"; + +const noop = () => {}; + +export function NewChatSkeletonFixture() { + const params = new URLSearchParams(location.search); + const sidebarExpanded = !params.has("collapsed"); + const sidebarWidth = Number(params.get("sidebarWidth") ?? 272); + const dark = params.has("dark"); + document.documentElement.classList.toggle("dark", dark); + return
+ {params.has("loading") ? : <> +
; +} diff --git a/webui/browser/new-chat-skeleton.spec.ts b/webui/browser/new-chat-skeleton.spec.ts new file mode 100644 index 000000000..362225517 --- /dev/null +++ b/webui/browser/new-chat-skeleton.spec.ts @@ -0,0 +1,67 @@ +import { expect, test, type Locator } from "@playwright/test"; + +const cases = [ + { name: "phone", width: 390, height: 844, touch: true, extra: "" }, + { name: "reported viewport", width: 946, height: 936, touch: false, extra: "" }, + { name: "desktop", width: 1440, height: 936, touch: false, extra: "" }, + { name: "sidebar rail", width: 1440, height: 936, touch: false, extra: "&collapsed" }, + { name: "custom sidebar", width: 1440, height: 936, touch: false, extra: "&sidebarWidth=384" }, + { name: "compact desktop composer", width: 1024, height: 936, touch: false, extra: "&sidebarWidth=480" }, + { name: "wide desktop", width: 1920, height: 1080, touch: false, extra: "" }, +]; + +async function box(locator: Locator) { + await expect(locator).toBeVisible(); + return (await locator.boundingBox())!; +} + +function sameBox(actual: Awaited>, expected: typeof actual) { + for (const key of ["x", "y", "width", "height"] as const) { + // The live thread camera can retain its 1px scroll anchor after initial focus. + expect(Math.abs(actual[key] - expected[key]), key).toBeLessThanOrEqual(1); + } +} + +for (const c of cases) for (const locale of ["en", "zh-CN"]) { + test.describe(`${c.name} ${locale} new chat`, () => { + test.use({ viewport: { width: c.width, height: c.height }, hasTouch: c.touch, reducedMotion: "reduce" }); + test("aligns the document skeleton with the real welcome, composer and header", async ({ page }) => { + await page.addInitScript((language) => { + Math.random = () => 0; + localStorage.setItem("nanobot.locale", language); + }, locale); + await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } })); + const url = `/browser/fixture.html?case=new-chat-skeleton${c.extra}${locale === "zh-CN" ? "&dark" : ""}`; + await page.goto(url); + await expect(page.locator(".thread-composer-surface")).toBeVisible(); + await page.evaluate(async () => { await document.fonts.ready; }); + const loaded = { + header: await box(page.getByTestId("thread-header")), + controls: await page.getByTestId("thread-header").locator("button:visible").evaluateAll((elements) => elements.map((e) => { + const { x, y, width, height } = e.getBoundingClientRect(); + return { x, y, width, height }; + })), + composer: await box(page.locator(".thread-composer-surface")), + input: await box(page.locator(".thread-composer-input")), + footer: await box(page.locator(".thread-composer-footer")), + greeting: await box(page.getByTestId("hero-greeting")), + workspaceRow: await page.locator(".thread-composer-workspace-row").isVisible() + ? await box(page.locator(".thread-composer-workspace-row")) : null, + }; + await page.goto(`${url}&loading`); + sameBox(await box(page.locator(".startup-chat-header")), loaded.header); + sameBox(await box(page.locator(".startup-composer-surface")), loaded.composer); + sameBox(await box(page.locator(".startup-composer-input")), loaded.input); + sameBox(await box(page.locator(".startup-composer-footer")), loaded.footer); + if (loaded.workspaceRow) sameBox(await box(page.locator(".startup-workspace-row")), loaded.workspaceRow); + const controls = page.locator(".startup-header-menu:visible, .startup-header-actions > div"); + await expect(controls).toHaveCount(loaded.controls.length); + for (let i = 0; i < loaded.controls.length; i++) sameBox(await box(controls.nth(i)), loaded.controls[i]); + const greeting = await box(page.locator(".startup-welcome-line")); + if (c.width < 640) expect(Math.abs(greeting.y + greeting.height / 2 - loaded.greeting.y - loaded.greeting.height / 2)).toBeLessThanOrEqual(1); + else expect(Math.abs(greeting.y + greeting.height - loaded.greeting.y - loaded.greeting.height)).toBeLessThanOrEqual(1); + expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false); + await expect(page.getByRole("status")).toHaveText("Loading nanobot…"); + }); + }); +} diff --git a/webui/browser/skeleton-additions-fixture.tsx b/webui/browser/skeleton-additions-fixture.tsx new file mode 100644 index 000000000..7855e15d2 --- /dev/null +++ b/webui/browser/skeleton-additions-fixture.tsx @@ -0,0 +1,141 @@ +import { useLayoutEffect, useState } from "react"; + +import { LinearMemberAccessView } from "../../nanobot/channels/linear/webui/LinearMemberAccessView"; +import type { LinearMembersPayload } from "../../nanobot/channels/linear/webui/types"; +import { ChatList } from "@/components/ChatList"; +import { SettingsPage } from "@/components/settings/SettingsPage"; +import type { SettingsSectionKey } from "@/components/settings/contracts"; +import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings"; +import { AutomationsSettings } from "@/components/settings/system/AutomationsSettings"; +import { RUNTIME_CONFIG_FIELDS } from "@/components/settings/system/runtime-config-fields"; +import { useSettingsController } from "@/components/settings/useSettingsController"; +import { SessionInfoPopoverView } from "@/components/thread/SessionInfoPopoverView"; +import { settings } from "@/dev/gallery/settings"; +import { setAppLanguage } from "@/i18n"; +import type { ChatSummary, SessionAutomationJob, SettingsPayload, SkillDetail } from "@/lib/types"; + +const noop = () => {}; +const now = Date.now(); +const names = ["Project summary", "Review changes", "Release checklist", "Documentation"]; +const jobs: SessionAutomationJob[] = names.slice(0, 3).map((name, index) => ({ + id: `preview-${index}`, name, enabled: true, schedule: { kind: "every", every_ms: 3_600_000 }, + payload: { message: "Summarize the project." }, state: { next_run_at_ms: now + index * 86_400_000 + 3_600_000 }, +})); +const sessions: ChatSummary[] = names.map((title, index) => ({ + key: `websocket:preview-${index}`, chatId: `preview-${index}`, channel: "websocket", title, preview: "", + handle: { id: `preview-${index}`, name: `topic${index}` }, + createdAt: new Date(now).toISOString(), updatedAt: new Date(now).toISOString(), +})); +const skill: SkillDetail = { + name: "project-review", description: "Review the repository and summarize actionable changes.", source: "builtin", available: true, enabled: true, + requirements: { bins: [], env: [], missing_bins: [], missing_env: [] }, raw_markdown: "# Project review\n\nRead the repository instructions before reviewing changes.", +}; +const members: LinearMembersPayload = { + session_id: "", status: "members", organization_id: "preview", legacy_allow_all: false, + members: names.slice(0, 3).map((_, index) => ({ id: `member-${index}`, name: ["Alex Chen", "Morgan Lee", "Sam Rivera"][index], teams: [], allowed: index === 0 })), +}; +const previewSettings: SettingsPayload = { + ...settings, + advanced: { ...settings.advanced, exec_max_runtime_limit: 86400 }, + model_presets: [{ name: "default", model: "gpt-5.4", provider: "openai", resolved_provider: "openai", active: true, is_default: true, + max_tokens: 8192, context_window_tokens: 200_000, temperature: 0.1, reasoning_effort: null }], + model_call_order: ["default"], + runtime_config: Object.fromEntries(RUNTIME_CONFIG_FIELDS.map((field) => [field.path, + field.kind === "boolean" ? true : field.kind === "toggle" ? field.options?.[1] ?? "" : field.kind === "list" ? [] : field.kind === "number" ? 20 : field.kind === "duration" ? 3600 : "", + ])), +}; +let detailState = "loaded"; + +export function installSkeletonPreviewApi() { + const fetch = window.fetch.bind(window); + window.fetch = async (input, init) => { + const url = new URL(input instanceof Request ? input.url : String(input), location.href); + if (url.origin !== location.origin || !url.pathname.startsWith("/api/")) return fetch(input, init); + if ((init?.method ?? "GET") !== "GET") return Response.json({ error: "Read-only preview" }, { status: 403 }); + if (url.pathname.startsWith("/api/webui/skills/")) { + if (detailState === "loading") await new Promise(() => {}); + return detailState === "error" ? Response.json({ error: "Preview read failed" }, { status: 503 }) : Response.json(skill); + } + const bodies: Record = { + "/api/settings": previewSettings, "/api/settings/usage": { usage: null }, + "/api/webui/automations": { jobs }, "/api/settings/nanobot-features": { features: [], enabled_count: 0, requires_restart: false }, + "/api/settings/cli-apps": { apps: [], installed_count: 0 }, "/api/settings/mcp-presets": { presets: [], installed_count: 0 }, + "/api/settings/api-service": { installed: false, running: false, managed: false, host: "127.0.0.1", port: 8900, timeout: 120, endpoint: "http://127.0.0.1:8900/v1", command: "nanobot serve" }, + }; + return Response.json(bodies[url.pathname] ?? {}); + }; +} + +export function SkeletonAdditionsFixture() { + return new URLSearchParams(location.search).has("preview") ? : ; +} + +function SkeletonPreview() { + const params = new URLSearchParams(location.search); + const [surface, setSurface] = useState(params.get("surface") ?? "chats"); + const [state, setState] = useState(params.get("state") ?? "loaded"); + const [section, setSection] = useState((params.get("section") ?? "appearance") as SettingsSectionKey); + const [density, setDensity] = useState<"compact" | "comfortable">(params.has("compact") ? "compact" : "comfortable"); + const [dark, setDark] = useState(false); + const [language, setLanguage] = useState(document.documentElement.lang); + const source = new URLSearchParams({ case: "skeleton-additions", surface, state, section }); + if (density === "compact") source.set("compact", ""); + if (dark) source.set("dark", ""); + const changeLanguage = (next: Parameters[0]) => { void setAppLanguage(next).then(() => setLanguage(next)); }; + return
+ +