fix(webui): show route-aligned skeletons from first paint (#6303)
This commit is contained in:
1 parent
af68da3280
commit
5d886fbb20
43 files changed
+1592
-213
No files matched your search
@@ -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 ? <p className="settings-list-inset py-3 text-[12px] text-muted-foreground">
|
||||
{tx("members.empty", "No matching active members.")}
|
||||
</p> : null}
|
||||
<SettingsGroup>
|
||||
{expanded && loading && !payload ? <SkeletonStatus label={tx("members.loading", "Finding members…")} className="space-y-0">
|
||||
{[0, 1, 2].map((index) => <div key={index} data-member-skeleton-row className="settings-disclosure-row">
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
<div className="h-8 w-8 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
<div className="flex min-w-0 flex-1 flex-col justify-center gap-1.5"><div className="h-3 w-24 rounded bg-muted-foreground/20" /></div>
|
||||
</div>
|
||||
<div className="h-5 w-[38px] rounded-full bg-muted-foreground/20" />
|
||||
</div>)}
|
||||
</SkeletonStatus> : <SettingsGroup>
|
||||
<ul className="max-h-80 overflow-y-auto" aria-label={tx("members.title", "Member access")}>
|
||||
{visible.map((member) => {
|
||||
const save = saves[member.id];
|
||||
@@ -135,7 +144,7 @@ export function LinearMemberAccessView({ snapshot, disabled = false, onLoad, onS
|
||||
</li>;
|
||||
})}
|
||||
</ul>
|
||||
</SettingsGroup>
|
||||
</SettingsGroup>}
|
||||
</DisclosureContent>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -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}
|
||||
/></main>;
|
||||
}
|
||||
if (parameters.get("case") === "skeleton-additions") installSkeletonPreviewApi();
|
||||
await initializeI18n();
|
||||
createRoot(document.getElementById("root")!).render(<TooltipProvider>
|
||||
{parameters.get("case") === "apps"
|
||||
{parameters.get("case") === "new-chat-skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><NewChatSkeletonFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton-additions"
|
||||
? <ClientProvider client={railClient} token="fixture"><SkeletonAdditionsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><SkeletonFixture surface={parameters.get("surface") ?? "skills"} loading={parameters.has("loading")} /></ClientProvider>
|
||||
: parameters.get("case") === "apps"
|
||||
? <ClientProvider client={railClient} token="fixture"><AppsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "rail"
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><RailFixture /></ClientProvider>
|
||||
|
||||
@@ -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 <div className="flex overflow-hidden bg-background" style={{ height: "100dvh" }}>
|
||||
{params.has("loading") ? <StartupSkeleton sidebarExpanded={sidebarExpanded} sidebarWidth={sidebarWidth} /> : <>
|
||||
<aside className="hidden shrink-0 bg-sidebar lg:block" style={{ width: sidebarExpanded ? sidebarWidth : 56 }} />
|
||||
<main className="thread-workspace relative flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<ThreadShell session={null} title="nanobot" onToggleSidebar={noop} theme={dark ? "dark" : "light"}
|
||||
hideSidebarToggleForHostChrome onTemporaryChatEnabledChange={noop} settingsSnapshot={settings}
|
||||
workspaceScope={{ project_path: "/workspace", access_mode: "full" }}
|
||||
workspaceDefaultScope={{ project_path: "/workspace", access_mode: "full" }}
|
||||
workspaceControls={{ can_change_project: true, can_browse_directories: true }} onWorkspaceScopeChange={noop} />
|
||||
</main>
|
||||
</>}
|
||||
</div>;
|
||||
}
|
||||
@@ -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<ReturnType<typeof box>>, 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…");
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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<void>(() => {});
|
||||
return detailState === "error" ? Response.json({ error: "Preview read failed" }, { status: 503 }) : Response.json(skill);
|
||||
}
|
||||
const bodies: Record<string, unknown> = {
|
||||
"/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") ? <SkeletonPreview /> : <SkeletonSurface />;
|
||||
}
|
||||
|
||||
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<SettingsSectionKey>((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<typeof setAppLanguage>[0]) => { void setAppLanguage(next).then(() => setLanguage(next)); };
|
||||
return <div style={{ height: "100dvh", display: "flex", flexDirection: "column" }}>
|
||||
<nav style={{ position: "sticky", top: 0, zIndex: 100, display: "flex", flexWrap: "wrap", alignItems: "center", gap: 12, padding: "12px 16px" }} className="border-b bg-background text-sm" aria-label="Skeleton preview controls">
|
||||
<span className="font-medium">首载骨架验收</span>
|
||||
<select aria-label="Surface" value={surface} onChange={(event) => setSurface(event.target.value)} className="rounded border bg-background p-1">
|
||||
{["chats", "settings", "automations", "skill-detail", "session-jobs", "linear-members"].map((name) => <option key={name}>{name}</option>)}
|
||||
</select>
|
||||
<select aria-label="State" value={state} onChange={(event) => setState(event.target.value)} className="rounded border bg-background p-1">
|
||||
{["loading", "loaded", "refresh", "error"].map((name) => <option key={name}>{name}</option>)}
|
||||
</select>
|
||||
{surface === "settings" ? <select aria-label="Section" value={section} onChange={(event) => setSection(event.target.value as SettingsSectionKey)} className="rounded border bg-background p-1">
|
||||
{["overview", "appearance", "models", "capabilities", "runtime", "advanced", "about", "channels", "apps", "skills", "automations"].map((name) => <option key={name}>{name}</option>)}
|
||||
</select> : null}
|
||||
{surface === "chats" ? <button onClick={() => setDensity(density === "compact" ? "comfortable" : "compact")}>{density}</button> : null}
|
||||
<button onClick={() => { document.documentElement.classList.toggle("dark", !dark); setDark(!dark); }}>{dark ? "浅色" : "深色"}</button>
|
||||
<button onClick={() => changeLanguage("zh-CN")}>中文</button><button onClick={() => changeLanguage("en")}>English</button>
|
||||
<span className="text-xs text-muted-foreground">固定展示状态;仅示例数据,无模型调用</span>
|
||||
</nav>
|
||||
<iframe key={language} title="首载骨架预览" src={`/browser/fixture.html?${source}`} style={{ width: "100%", minHeight: 0, flex: 1, border: 0 }} />
|
||||
</div>;
|
||||
}
|
||||
|
||||
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 <div data-testid="skeleton-additions" className="min-h-[85vh] bg-settings-canvas">
|
||||
{surface === "settings" ? <div style={{ minHeight: "85vh" }} className="flex flex-col"><SettingsPage controller={{ ...controller, loading, settings: empty ? null : previewSettings, error: state === "error" ? "Preview read failed" : null,
|
||||
systemState: { ...controller.systemState,
|
||||
cliApps: empty ? null : { apps: [], installed_count: 0 }, cliAppsLoading: loading,
|
||||
mcpPresets: empty ? null : { presets: [], installed_count: 0 }, mcpPresetsLoading: loading,
|
||||
nanobotFeatures: empty ? null : { features: [], enabled_count: 0, requires_restart: false }, nanobotFeaturesLoading: loading,
|
||||
automations: empty ? null : { jobs }, automationsLoading: loading,
|
||||
automationsError: state === "error" ? "Preview read failed" : null,
|
||||
},
|
||||
}}
|
||||
theme={dark ? "dark" : "light"} showSidebar mainNavigationExpanded={false} onToggleTheme={noop} onBackToChat={noop}
|
||||
skills={empty ? [] : [skill]} skillsLoading={loading && empty} skillsError={state === "error"} isRestarting={false} hostChromeInset={false} /></div>
|
||||
: <main className="settings-grid mx-auto w-full p-4" style={surface === "automations" ? { maxWidth: 960 } : undefined}>
|
||||
{surface === "chats" ? <div style={{ height: 440, width: 280, maxWidth: "100%" }} className="bg-sidebar"><ChatList sessions={empty ? [] : sessions} activeKey={null} loading={loading} density={density}
|
||||
onSelect={noop} onRequestDelete={noop} onTogglePin={noop} onToggleArchive={noop} onRequestRename={async () => {}} /></div>
|
||||
: surface === "automations" ? <AutomationsSettings payload={empty ? null : { jobs }} loading={loading} filter="all" actionKey={null} error={state === "error" ? "Preview read failed" : null}
|
||||
onFilterChange={noop} onAction={noop} onRequestEdit={noop} onRequestDelete={noop} />
|
||||
: surface === "skill-detail" ? <SkillsCatalogSettings skills={[skill]} />
|
||||
: surface === "session-jobs" ? <SessionInfoPopoverView title="Project review" jobs={empty ? [] : jobs} loading={loading} loadFailed={state === "error"} now={now}
|
||||
onAction={async () => jobs} onEdit={async () => jobs} />
|
||||
: surface === "linear-members" ? <LinearMemberAccessView snapshot={{ payload: empty ? null : members, loading, error: state === "error" ? "Preview read failed" : null, saves: {} }} onLoad={noop} onSetAllowed={noop} /> : null}
|
||||
</main>}
|
||||
</div>;
|
||||
}
|
||||
@@ -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<ReturnType<typeof boxes>>, 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();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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 <main className="settings-grid mx-auto w-full max-w-4xl p-4" data-testid="skeleton-fixture">
|
||||
{surface === "workspace" ? <WorkspaceProjectPicker isHero scope={{ project_path: "/srv/workspace", access_mode: "restricted" }}
|
||||
defaultScope={{ project_path: "/srv/workspace", access_mode: "restricted" }}
|
||||
controls={{ can_change_project: true, can_browse_directories: true }}
|
||||
onBrowseDirectories={(path, query, showHidden, allowPartial) => fetchWorkspaceDirectories("fixture", path, query, showHidden, allowPartial)}
|
||||
onChange={noop} /> : surface === "apps" || surface === "cli" ? <AppsCatalogSettings
|
||||
cliApps={{ apps: surface === "cli" && !loading ? names.map((name, index) => ({
|
||||
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" ? <ChannelsSettings
|
||||
token="fixture" nanobotFeatures={loading ? null : { features: names.map((name, index) => ({ ...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" ? <SkillsCatalogSettings loading={loading} skills={loading ? [] : names.map((name) => ({
|
||||
name, description: "Search, inspect and maintain the project.", source: "builtin", available: true, enabled: true,
|
||||
}))} /> : surface === "marketplace" ? <SkillsMarketplace installedSkills={[]} installing="" onInstallingChange={noop} />
|
||||
: surface === "models" || surface === "models-compact" ? <ModelIdPicker token="fixture"
|
||||
settings={{ ...settings, providers: settings.providers.map((provider) => provider.name === "openai" ? { ...provider, model_catalog: "official" } : provider) }}
|
||||
provider={surface === "models-compact" ? "openai" : "anthropic"}
|
||||
value={model} showProviderLogos={false} onChange={setModel} />
|
||||
: surface === "tools" ? <McpManagementDialog
|
||||
preset={{ ...preset, tool_names: loading ? [] : names.map((_, index) => `read_project_${index}`), tool_count: loading ? 0 : 6 }}
|
||||
values={{}} actionKey={loading ? "test:docs" : null} statusLabel="Connected" statusTone="success" tab="tools"
|
||||
icon={<span aria-hidden>DM</span>} onTabChange={noop} onOpenChange={noop} onFieldChange={noop}
|
||||
onAction={noop} onOAuthConnect={noop} onToolsChange={noop}
|
||||
/> : surface === "file" || surface === "markdown" ? <div className="flex flex-col" style={{ height: 560 }}><FilePreviewPanelView path={surface === "markdown" ? "/project/README.md" : "/project/main.py"}
|
||||
state={previewLoading ? { status: "loading" } : { status: "ready", payload: {
|
||||
kind: "text", path: surface === "markdown" ? "/project/README.md" : "/project/main.py", display_path: "project file", project_path: "/project", size: 400,
|
||||
language: surface === "markdown" ? "markdown" : "python", truncated: false,
|
||||
content: surface === "markdown" ? "# Project overview\n\nSearch, inspect and maintain the project.\n\nReview the results before making changes." : names.map((name, index) => `value_${index} = ${JSON.stringify(name)}`).join("\n"),
|
||||
} }} imageOpen={false} onImageOpenChange={noop} onImageError={noop} /></div> : null}
|
||||
{surface === "file" || surface === "markdown" ? <button data-testid="reload-preview" style={{ position: "fixed", bottom: 8, left: 8 }} onClick={() => setPreviewLoading(true)}>Reload preview</button> : null}
|
||||
</main>;
|
||||
}
|
||||
@@ -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<void> | 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<void>((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<void> | 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<void>((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<void>((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]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
+3
-27
@@ -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); }
|
||||
</style>
|
||||
<!--startup-style-->
|
||||
<script>
|
||||
(function () {
|
||||
try {
|
||||
@@ -120,18 +106,8 @@
|
||||
</head>
|
||||
<body class="bg-background text-foreground antialiased">
|
||||
<div class="pwa-status-bar-surface" aria-hidden="true"></div>
|
||||
<div id="root">
|
||||
<main class="startup-shell" aria-busy="true">
|
||||
<div class="startup-header" aria-hidden="true">
|
||||
<span class="startup-control-shadow"></span>
|
||||
<span class="startup-control-shadow"></span>
|
||||
</div>
|
||||
<div class="startup-composer" aria-hidden="true"></div>
|
||||
<div class="startup-status" role="status">
|
||||
<span data-boot-copy>Loading nanobot…</span>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div id="root"><!--startup-shell--></div>
|
||||
<!--startup-script-->
|
||||
<script>
|
||||
(function () {
|
||||
var localeKey = "nanobot.locale";
|
||||
|
||||
+4
-18
@@ -170,22 +170,6 @@ const RenameDialog = lazy(async () => {
|
||||
return { default: module.RenameDialog };
|
||||
});
|
||||
|
||||
function SurfaceLoadingFallback({ label }: { label?: string }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
aria-busy="true"
|
||||
className="flex h-full w-full flex-col gap-5 px-5 py-8 sm:px-8 lg:px-12"
|
||||
>
|
||||
<span className="sr-only">{label ?? t("settings.status.loading")}</span>
|
||||
<div className="h-4 w-20 animate-pulse rounded bg-muted/70 motion-reduce:animate-none" />
|
||||
<div className="h-9 w-48 animate-pulse rounded bg-muted/70 motion-reduce:animate-none" />
|
||||
<div className="mt-4 h-12 w-full max-w-3xl animate-pulse rounded-md bg-muted/55 motion-reduce:animate-none" />
|
||||
<div className="h-28 w-full max-w-3xl animate-pulse rounded-md bg-muted/40 motion-reduce:animate-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const SETTINGS_SECTION_KEYS: SettingsSectionKey[] = [
|
||||
"capabilities",
|
||||
"overview",
|
||||
@@ -1199,6 +1183,7 @@ function Shell({
|
||||
const {
|
||||
sessions,
|
||||
loading,
|
||||
initialLoading: sessionsInitialLoading,
|
||||
error: sessionsError,
|
||||
refresh,
|
||||
createChat,
|
||||
@@ -2760,6 +2745,7 @@ function Shell({
|
||||
? (temporaryChatActive ? activeKey : activeSidebarKey)
|
||||
: null,
|
||||
loading: loading || sidebarStateLoading,
|
||||
initialLoading: sessionsInitialLoading || sidebarStateLoading,
|
||||
newChatActive: !managingConnections && view === "chat" && activeKey === null,
|
||||
onNewChat,
|
||||
onSelect: onSelectSidebarItem,
|
||||
@@ -2953,7 +2939,7 @@ function Shell({
|
||||
)}
|
||||
>
|
||||
<ThreadVisibilityContext.Provider value={localActive && !managingConnections && view === "chat"}>
|
||||
<Suspense fallback={<StartupShell embedded />}>
|
||||
<Suspense fallback={<StartupShell embedded surface="chat" sidebarExpanded={hostSidebarOpen} />}>
|
||||
<PaneWorkbench
|
||||
panes={renderedWorkbenchPanes}
|
||||
activePaneKey={renderedActivePaneKey}
|
||||
@@ -3104,7 +3090,7 @@ function Shell({
|
||||
mainNavigationExpanded={showMainSidebar && hostSidebarOpen}
|
||||
hostChromeInset={showHostChrome}
|
||||
onBackToChat={onBackToChat}
|
||||
/> : <Suspense fallback={<SurfaceLoadingFallback />}>
|
||||
/> : <Suspense fallback={<StartupShell embedded surface={view} sidebarExpanded={hostSidebarOpen} />}>
|
||||
<SettingsView
|
||||
registerExitGuard={registerSettingsExitGuard}
|
||||
theme={theme}
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
} from "@/components/ui/tooltip";
|
||||
import { MAX_WORKBENCH_PANES } from "@/components/workbench/workbench-model";
|
||||
import { SidebarTopicRename } from "@/components/SidebarTopicRename";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import {
|
||||
SIDEBAR_SELECTION_ITEM_CLASS,
|
||||
SidebarSelectionHighlight,
|
||||
@@ -258,6 +259,7 @@ interface ChatListProps {
|
||||
defaultWorkspacePath?: string | null;
|
||||
actionMenuPortalContainer?: HTMLElement | null;
|
||||
loading?: boolean;
|
||||
initialLoading?: boolean;
|
||||
emptyLabel?: string;
|
||||
}
|
||||
|
||||
@@ -299,6 +301,7 @@ export const ChatList = memo(function ChatList({
|
||||
defaultWorkspacePath,
|
||||
actionMenuPortalContainer,
|
||||
loading,
|
||||
initialLoading = loading,
|
||||
emptyLabel,
|
||||
}: ChatListProps) {
|
||||
const { t } = useTranslation();
|
||||
@@ -573,11 +576,22 @@ export const ChatList = memo(function ChatList({
|
||||
for (const animation of layoutAnimationsRef.current.values()) animation.cancel();
|
||||
}, []);
|
||||
|
||||
if (loading && sessions.length === 0 && temporarySessions.length === 0) {
|
||||
if (initialLoading && sessions.length === 0 && temporarySessions.length === 0) {
|
||||
return (
|
||||
<div className="px-3 py-6 text-[12px] text-sidebar-muted-foreground">
|
||||
{t("chat.loading")}
|
||||
</div>
|
||||
<SkeletonStatus label={t("chat.loading")} className="px-2 py-1.5">
|
||||
<div className="flex h-8 items-center px-2"><div className="h-2.5 w-14 rounded bg-sidebar-muted-foreground/15" /></div>
|
||||
<div className="space-y-0.5">
|
||||
{[64, 76, 56, 70, 60, 72].map((width, index) => (
|
||||
<div key={index} data-chat-skeleton-row className={cn("flex items-center gap-1 px-2", density === "compact" ? "h-[30px]" : "h-[34px]", "[@media(pointer:coarse)]:h-11")}>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5">
|
||||
<div className="h-2.5 w-10 shrink-0 rounded bg-sidebar-muted-foreground/15" />
|
||||
<div className="h-3 rounded bg-sidebar-muted-foreground/20" style={{ width: `${width}%` }} />
|
||||
</div>
|
||||
<div className="h-4 w-4 shrink-0" /><div className="h-6 w-6 shrink-0" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</SkeletonStatus>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [mode, setMode] = useState<"preview" | "source">("preview");
|
||||
const previewKind = fileKindForPath(path);
|
||||
const markdown = state.status === "ready" && state.payload.kind !== "image"
|
||||
&& state.payload.language === "markdown";
|
||||
const displayPath = state.status === "ready" ? state.payload.display_path : path;
|
||||
@@ -50,12 +51,29 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
className="min-h-0 flex-1 overflow-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60">
|
||||
{state.status === "loading" ? (
|
||||
<div role="status" aria-label={t("filePreview.loading", { defaultValue: "Loading preview..." })}
|
||||
className="flex h-full flex-col justify-center gap-3 p-6" aria-busy="true">
|
||||
className="h-full" aria-busy="true">
|
||||
<span className="sr-only">{t("filePreview.loading", { defaultValue: "Loading preview..." })}</span>
|
||||
<div aria-hidden className="mx-auto w-full max-w-sm space-y-3 animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{fileKindForPath(path) === "image" ? <div className="aspect-[8/5] rounded-compact bg-muted/40" />
|
||||
: <>{["w-2/3", "w-full", "w-5/6", "w-3/4"].map((width) =>
|
||||
<div key={width} className={`h-1.5 rounded-full bg-muted/40 ${width}`} />)}</>}
|
||||
<div aria-hidden className="h-full animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{previewKind === "image" ? <div className="flex h-full items-center justify-center p-4">
|
||||
<div className="aspect-[8/5] w-full max-w-sm rounded-compact bg-muted/40" />
|
||||
</div> : <>
|
||||
{previewKind === "markdown" ? <div className="flex justify-end px-4 py-2">
|
||||
<div className="inline-flex min-h-8 items-center gap-1 rounded-full bg-muted/40 p-1 text-[12px] font-medium">
|
||||
{[t("filePreview.preview"), t("filePreview.source")].map((label) => <span key={label} className="invisible px-3 py-1 [@media(pointer:coarse)]:min-h-9">{label}</span>)}
|
||||
</div>
|
||||
</div> : null}
|
||||
{previewKind === "markdown" && mode === "preview" ? <div className="px-5 pb-6 pt-1 text-sm sm:px-6">
|
||||
<div className="flex h-7 items-center"><div className="h-5 w-2/3 rounded bg-muted/40" /></div>
|
||||
{["w-full", "w-5/6", "w-3/4"].map((width) => <div key={width} className="mt-4 flex h-[1.625em] items-center">
|
||||
<div className={`h-3 rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div> : <div className="px-4 py-3 font-mono text-[13px] leading-[1.55]">
|
||||
{["w-2/3", "w-full", "w-5/6", "w-3/4", "w-1/2", "w-3/5"].map((width) => <div key={width} className="flex h-[1.55em] items-center">
|
||||
<div className="w-[4.25em] shrink-0 pr-[1.15rem]"><div className="ml-auto h-3 w-2 rounded bg-muted/40" /></div>
|
||||
<div className={`h-3 max-w-[calc(100%-4.25em)] rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div>}
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
) : state.status === "error" ? (
|
||||
|
||||
@@ -42,6 +42,7 @@ interface SidebarProps {
|
||||
temporarySessions?: ChatSummary[];
|
||||
activeKey: string | null;
|
||||
loading: boolean;
|
||||
initialLoading?: boolean;
|
||||
newChatActive: boolean;
|
||||
onNewChat: () => void;
|
||||
onSelect: (key: string) => void;
|
||||
@@ -272,6 +273,7 @@ export function Sidebar(props: SidebarProps) {
|
||||
temporarySessions={props.temporarySessions}
|
||||
activeKey={props.activeKey}
|
||||
loading={props.loading}
|
||||
initialLoading={props.initialLoading}
|
||||
emptyLabel={t("chat.noSessions")}
|
||||
onSelect={props.onSelect}
|
||||
onCloseTemporaryChat={props.onCloseTemporaryChat}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
/** Quiet layout placeholders while the authenticated application starts. */
|
||||
export function StartupShell({ embedded = false }: { embedded?: boolean }) {
|
||||
import { readStartupLayout, StartupSkeleton, type StartupSurface } from "./StartupSkeleton";
|
||||
|
||||
export function StartupShell({ embedded = false, surface, sidebarExpanded }: {
|
||||
embedded?: boolean;
|
||||
surface?: StartupSurface;
|
||||
sidebarExpanded?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const Root = embedded ? "section" : "main";
|
||||
return (
|
||||
<Root className="startup-shell" aria-busy="true">
|
||||
<div className="startup-header" aria-hidden="true">
|
||||
<span className="startup-control-shadow" />
|
||||
<span className="startup-control-shadow" />
|
||||
</div>
|
||||
<div className="startup-composer" aria-hidden="true" />
|
||||
<span className="startup-status" role="status">{t("app.loading.connecting")}</span>
|
||||
</Root>
|
||||
);
|
||||
const layout = readStartupLayout();
|
||||
return <StartupSkeleton {...layout} embedded={embedded} surface={surface ?? layout.surface}
|
||||
sidebarExpanded={sidebarExpanded ?? layout.sidebarExpanded} label={t("app.loading.boot")} />;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
export type StartupSurface = "chat" | "settings" | "skills" | "apps" | "channels" | "automations" | "remote";
|
||||
|
||||
/** Also inlined in index.html: keep document startup independent of app modules. */
|
||||
export function readStartupLayout() {
|
||||
let hash = window.location.hash.slice(1);
|
||||
let sidebarExpanded = true;
|
||||
let sidebarWidth = 272;
|
||||
try {
|
||||
if ((!hash || hash === "/" || hash === "/new")
|
||||
&& Date.now() - Number(localStorage.getItem("nanobot-webui.restartStartedAt") || 0) < 300_000) {
|
||||
hash = (localStorage.getItem("nanobot-webui.restartRoute") || hash).replace(/^#/, "");
|
||||
}
|
||||
const stored = localStorage.getItem("nanobot-webui.sidebar");
|
||||
sidebarExpanded = stored === null || stored === "1";
|
||||
const width = Number(localStorage.getItem("nanobot-webui.sidebar.width"));
|
||||
if (Number.isFinite(width) && width >= 220) sidebarWidth = Math.min(480, width);
|
||||
} catch {
|
||||
// Storage can be unavailable in private browsing; use the shell's defaults.
|
||||
}
|
||||
const [path, query = ""] = hash.split("?", 2);
|
||||
const section = new URLSearchParams(query).get("section") || "overview";
|
||||
const page = path === "/settings" ? section : path.slice(1);
|
||||
let surface: StartupSurface = "chat";
|
||||
if (page === "skills" || page === "apps" || page === "channels" || page === "automations" || page === "remote") surface = page;
|
||||
else if (path === "/settings") surface = "settings";
|
||||
const now = new Date();
|
||||
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
const days = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate();
|
||||
const calendarWeeks = Math.ceil(((firstDay.getDay() + 6) % 7 + days) / 7);
|
||||
return { surface, section, sidebarExpanded, sidebarWidth, calendarWeeks, existingChat: /^\/(chat|temporary)\/.+/.test(path) };
|
||||
}
|
||||
|
||||
interface StartupSkeletonProps {
|
||||
surface?: StartupSurface;
|
||||
section?: string;
|
||||
sidebarExpanded?: boolean;
|
||||
sidebarWidth?: number;
|
||||
existingChat?: boolean;
|
||||
calendarWeeks?: number;
|
||||
embedded?: boolean;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function Block({ className = "" }: { className?: string }) {
|
||||
return <div className={`startup-block ${className}`} />;
|
||||
}
|
||||
|
||||
/** One markup/CSS contract for the HTML first paint and React's loading boundaries. */
|
||||
export function StartupSkeleton({
|
||||
surface = "chat", section = "overview", sidebarExpanded = true, sidebarWidth = 272,
|
||||
existingChat = false, calendarWeeks = 5, embedded = false, label = "Loading nanobot…",
|
||||
}: StartupSkeletonProps) {
|
||||
const Root = embedded ? "section" : "main";
|
||||
return (
|
||||
<Root className="startup-shell" aria-busy="true" data-startup-surface={surface}
|
||||
data-startup-section={section} data-sidebar-expanded={sidebarExpanded} data-existing-chat={existingChat}
|
||||
data-calendar-weeks={calendarWeeks} data-embedded={embedded}
|
||||
style={{ "--startup-sidebar-width": `${sidebarExpanded ? sidebarWidth : 56}px` } as CSSProperties}>
|
||||
<span className="startup-status" role="status" data-boot-copy>{label}</span>
|
||||
<div className="startup-navigation" aria-hidden="true">
|
||||
<Block className="startup-nav-brand" />
|
||||
{Array.from({ length: 7 }, (_, index) => <div key={index} className="startup-nav-row"><Block className="startup-nav-icon" /><Block className="startup-nav-label" /></div>)}
|
||||
</div>
|
||||
<div className="startup-content" aria-hidden="true">
|
||||
<div className="startup-chat">
|
||||
<div className="startup-chat-header">
|
||||
<div className="startup-header-leading"><div className="startup-header-menu"><Block /></div><Block className="startup-header-title" /></div>
|
||||
<div className="startup-header-actions"><div><Block /></div><div><Block /></div></div>
|
||||
</div>
|
||||
<div className="startup-chat-viewport">
|
||||
<div className="startup-chat-layout">
|
||||
<div className="startup-messages"><Block /><Block /><Block /></div>
|
||||
<div className="startup-welcome"><div className="startup-welcome-line"><Block /></div></div>
|
||||
<div className="startup-composer">
|
||||
<div className="startup-composer-surface">
|
||||
<div className="startup-composer-input"><Block /></div>
|
||||
<div className="startup-composer-footer">
|
||||
<div className="startup-composer-primary"><Block className="startup-attach" /><Block className="startup-workspace" /><Block className="startup-access" /><Block className="startup-mobile-model" /></div>
|
||||
<div className="startup-composer-actions"><Block className="startup-model" /><Block className="startup-send" /></div>
|
||||
</div>
|
||||
<div className="startup-workspace-row"><Block /><Block /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-chat-spacer" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-scroll">
|
||||
<div className="startup-page">
|
||||
<div className="startup-page-header"><div className="startup-back"><Block /></div><div className="startup-title"><Block /></div></div>
|
||||
<div className="startup-tabs"><Block /></div>
|
||||
<div className="startup-panel">
|
||||
<div className="startup-toolbar"><Block className="startup-search" /><Block className="startup-filters" /></div>
|
||||
<div className="startup-catalog-frame">
|
||||
<div className="startup-catalog-heading"><Block /></div>
|
||||
<div className="startup-catalog">
|
||||
<div className="startup-catalog-group"><Block /></div>
|
||||
{Array.from({ length: 6 }, (_, index) => <div key={index} className="startup-catalog-row">
|
||||
<Block className="startup-catalog-icon" /><div className="startup-catalog-copy"><Block /><Block /></div><Block className="startup-catalog-action" />
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-automation">
|
||||
<div className="startup-automation-composer"><Block /></div>
|
||||
<div className="startup-calendar"><div className="startup-calendar-toolbar"><Block /><Block /><Block className="startup-calendar-navigation" /></div>
|
||||
<div className="startup-calendar-days">{Array.from({ length: 42 }, (_, index) => <div key={index}><Block /></div>)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-settings">
|
||||
{[0, 1].map((group) => <div key={group} className="startup-settings-group"><Block className="startup-settings-title" />
|
||||
{[0, 1, 2].map((row) => <div key={row} className="startup-settings-row"><Block /><Block /></div>)}
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ChevronLeft, Loader2 } from "lucide-react";
|
||||
import { ChevronLeft } from "lucide-react";
|
||||
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogLayoutContext, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { SettingsExitGuard } from "@/components/settings/contracts";
|
||||
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { SettingsFeature } from "@/components/settings/shared/SettingsFeature";
|
||||
import { SettingsSectionSkeleton } from "@/components/settings/shared/SettingsSectionSkeleton";
|
||||
|
||||
import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings";
|
||||
import { ImageGenerationSettings } from "@/components/settings/capabilities/ImageGenerationSettings";
|
||||
@@ -162,7 +163,7 @@ export function SettingsPage({
|
||||
</RuntimeConfigSettings>
|
||||
);
|
||||
|
||||
const renderSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
const renderSettingsSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
if (!settings) return null;
|
||||
switch (section) {
|
||||
case "capabilities": {
|
||||
@@ -400,6 +401,40 @@ export function SettingsPage({
|
||||
</WebSettings>
|
||||
</div>
|
||||
);
|
||||
case "runtime":
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{runtimeConfiguration("runtime")}
|
||||
<RuntimeSettings
|
||||
form={modelState.form}
|
||||
settings={settings}
|
||||
onRestart={showSidebar ? undefined : restartViaSettingsSurface}
|
||||
isRestarting={restartInProgress}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
apiService={systemState.apiService}
|
||||
apiServiceLoading={systemState.apiServiceLoading}
|
||||
apiServiceAction={systemState.apiServiceAction}
|
||||
apiServiceError={systemState.apiServiceError}
|
||||
langfuseFeature={featureCatalog.find((feature) => feature.name === "langfuse")}
|
||||
capabilitiesLoading={systemState.nanobotFeaturesLoading}
|
||||
capabilityAction={systemState.nanobotFeatureAction}
|
||||
capabilityError={systemState.nanobotFeaturesError}
|
||||
onApiServiceAction={systemActions.handleApiServiceAction}
|
||||
onInstallCapability={(name) => void systemActions.installCapabilities([name])}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
case "memory":
|
||||
return runtimeConfiguration("memory");
|
||||
case "advanced":
|
||||
return runtimeConfiguration("advanced");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const renderSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
switch (section) {
|
||||
case "channels":
|
||||
return (
|
||||
<ChannelsSettings
|
||||
@@ -413,7 +448,7 @@ export function SettingsPage({
|
||||
nanobotFeatures={systemState.nanobotFeatures}
|
||||
loading={systemState.nanobotFeaturesLoading}
|
||||
actionKey={systemState.nanobotFeatureAction}
|
||||
chatAppsDocsUrl={settings.docs?.chat_apps_url}
|
||||
chatAppsDocsUrl={settings?.docs?.chat_apps_url}
|
||||
showBrandLogos={localPrefs.brandLogos}
|
||||
error={systemState.nanobotFeaturesError}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
@@ -523,37 +558,12 @@ export function SettingsPage({
|
||||
);
|
||||
case "skills":
|
||||
return <SkillsCatalogSettings skills={skills} loading={skillsLoading} error={skillsError} />;
|
||||
case "runtime":
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{runtimeConfiguration("runtime")}
|
||||
<RuntimeSettings
|
||||
form={modelState.form}
|
||||
settings={settings}
|
||||
onRestart={showSidebar ? undefined : restartViaSettingsSurface}
|
||||
isRestarting={restartInProgress}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
apiService={systemState.apiService}
|
||||
apiServiceLoading={systemState.apiServiceLoading}
|
||||
apiServiceAction={systemState.apiServiceAction}
|
||||
apiServiceError={systemState.apiServiceError}
|
||||
langfuseFeature={featureCatalog.find((feature) => feature.name === "langfuse")}
|
||||
capabilitiesLoading={systemState.nanobotFeaturesLoading}
|
||||
capabilityAction={systemState.nanobotFeatureAction}
|
||||
capabilityError={systemState.nanobotFeaturesError}
|
||||
onApiServiceAction={systemActions.handleApiServiceAction}
|
||||
onInstallCapability={(name) => void systemActions.installCapabilities([name])}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
case "memory":
|
||||
return runtimeConfiguration("memory");
|
||||
case "advanced":
|
||||
return runtimeConfiguration("advanced");
|
||||
default:
|
||||
return null;
|
||||
return renderSettingsSection(section, embedded);
|
||||
}
|
||||
};
|
||||
const sectionReady = settings !== null || activeSection === "skills" || activeSection === "apps"
|
||||
|| activeSection === "channels" || activeSection === "automations";
|
||||
|
||||
return (
|
||||
<DialogLayoutContext.Provider value={dialogLayoutAnchor}>
|
||||
@@ -702,18 +712,15 @@ export function SettingsPage({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{loading ? (
|
||||
<div className="flex h-48 items-center justify-center rounded-panel bg-settings-surface text-sm text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
{t("settings.status.loading")}
|
||||
</div>
|
||||
) : error && !settings ? (
|
||||
{loading && !sectionReady ? (
|
||||
<SettingsSectionSkeleton section={activeSection} showRestart={!showSidebar} />
|
||||
) : error && !sectionReady ? (
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.status.loadError")}>
|
||||
<span className="max-w-[520px] text-sm text-muted-foreground">{error}</span>
|
||||
</SettingsRow>
|
||||
</SettingsGroup>
|
||||
) : settings ? (
|
||||
) : sectionReady ? (
|
||||
<div
|
||||
className={cn(
|
||||
"settings-stack",
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
CircleAlert,
|
||||
Copy,
|
||||
KeyRound,
|
||||
Loader2,
|
||||
PowerOff,
|
||||
RefreshCw,
|
||||
Search,
|
||||
@@ -32,6 +31,7 @@ import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
||||
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
|
||||
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { ToggleButton } from "@/components/ui/toggle-button";
|
||||
import { deleteSkill, fetchSkillDetail, updateSkillEnabled } from "@/lib/api";
|
||||
import { notifySkillsChanged, requestSkillsRefresh } from "@/lib/skill-events";
|
||||
@@ -200,6 +200,7 @@ export function SkillsCatalogSettings({ skills, loading = false, error = false }
|
||||
)}
|
||||
|
||||
<SkillDetailSheet
|
||||
key={selectedSkill ? `${selectedSkill.source}:${selectedSkill.name}` : "closed"}
|
||||
skill={selectedSkill}
|
||||
open={selectedSkill !== null}
|
||||
onOpenChange={(open) => {
|
||||
@@ -299,7 +300,6 @@ function SkillDetailSheet({
|
||||
useEffect(() => {
|
||||
if (!open || !skill) return;
|
||||
let cancelled = false;
|
||||
setDetail(null);
|
||||
setLoading(true);
|
||||
setLoadFailed(false);
|
||||
setActionError("");
|
||||
@@ -449,12 +449,22 @@ function SkillDetailSheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div className="mt-8 flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" aria-hidden />
|
||||
{t("settings.skills.loadingDetail", { defaultValue: "Loading skill details..." })}
|
||||
{loading && !detail ? (
|
||||
<div className="mt-6">
|
||||
<SkeletonStatus label={t("settings.skills.loadingDetail", { defaultValue: "Loading skill details..." })} className="space-y-5">
|
||||
<div data-skill-toggle-skeleton className="flex min-h-16 items-center justify-between gap-3 border-y border-border/45 px-1 py-3.5">
|
||||
<div className="h-3 w-28 rounded bg-muted-foreground/20" /><div className="h-5 w-[38px] rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
{!skill.available && enabled ? <div className="rounded-floating border border-border/45 p-4">
|
||||
<div className="h-4 w-28 rounded bg-muted-foreground/20" /><div className="mt-3 h-3 w-4/5 rounded bg-muted-foreground/15" />
|
||||
<div className="mt-3 h-9 w-24 rounded-full bg-muted-foreground/15" />
|
||||
</div> : null}
|
||||
<div data-skill-instructions-skeleton className="flex min-h-[70px] items-center justify-between rounded-floating border border-border/45 bg-muted/20 px-3 py-3">
|
||||
<div className="h-3 w-32 rounded bg-muted-foreground/20" /><div className="h-2.5 w-12 rounded bg-muted-foreground/15" />
|
||||
</div>
|
||||
</SkeletonStatus>
|
||||
</div>
|
||||
) : loadFailed ? (
|
||||
) : loadFailed && !detail ? (
|
||||
<div className="mt-8 rounded-floating bg-destructive/10 px-3 py-3 text-sm text-destructive">
|
||||
{t("settings.skills.loadFailed", { defaultValue: "Could not load skill details." })}
|
||||
</div>
|
||||
@@ -477,14 +487,14 @@ function SkillDetailSheet({
|
||||
defaultValue: "Enable {{name}}",
|
||||
})
|
||||
}
|
||||
disabled={actionBusy}
|
||||
disabled={actionBusy || loading}
|
||||
onChange={() => void toggleEnabled()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{actionError ? (
|
||||
<div className="rounded-control bg-destructive/10 px-3 py-2.5 text-[13px] text-destructive">
|
||||
{actionError}
|
||||
{actionError || loadFailed ? (
|
||||
<div role="alert" className="rounded-control bg-destructive/10 px-3 py-2.5 text-[13px] text-destructive">
|
||||
{actionError || t("settings.skills.loadFailed", { defaultValue: "Could not load skill details." })}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -513,7 +523,7 @@ function SkillDetailSheet({
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={actionBusy}
|
||||
disabled={actionBusy || loading}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
className={cn(
|
||||
"h-10 w-full shrink-0 rounded-full border-destructive/20 text-destructive",
|
||||
|
||||
@@ -253,7 +253,7 @@ export function SkillsMarketplace({
|
||||
) : null}
|
||||
</div>
|
||||
{trendingLoading ? (
|
||||
<MarketplaceSkeleton ranked />
|
||||
<MarketplaceSkeleton ranked provider={provider} />
|
||||
) : visibleTrending.length ? (
|
||||
<MarketplaceSkillGroups
|
||||
skills={visibleTrending}
|
||||
@@ -281,7 +281,7 @@ export function SkillsMarketplace({
|
||||
) : (
|
||||
<div className="overflow-hidden rounded-panel bg-settings-surface">
|
||||
{loading && !visibleResults.length ? (
|
||||
<MarketplaceSkeleton />
|
||||
<MarketplaceSkeleton provider={provider} />
|
||||
) : (
|
||||
<MarketplaceSkillGroups
|
||||
skills={visibleResults}
|
||||
@@ -674,26 +674,39 @@ function TrendSparkline({ values }: { values?: number[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function MarketplaceSkeleton({ ranked = false }: { ranked?: boolean }) {
|
||||
function MarketplaceSkeleton({ ranked = false, provider }: { ranked?: boolean; provider: MarketplaceProvider }) {
|
||||
const { t } = useTranslation();
|
||||
const grouped = provider === "all";
|
||||
const providers: Array<Exclude<MarketplaceProvider, "all">> = grouped ? ["skills_sh", "skillhub"] : [provider];
|
||||
return (
|
||||
<SkeletonStatus
|
||||
label={t("settings.skills.loading")}
|
||||
className="space-y-1 px-3 pb-3 sm:px-4"
|
||||
className={grouped ? "space-y-5 pb-3 pt-2" : ""}
|
||||
>
|
||||
{Array.from({ length: 5 }, (_, index) => (
|
||||
<div key={index} className="flex min-w-0 items-center gap-2 px-1 py-3.5 sm:gap-3 sm:px-2">
|
||||
{ranked ? <div className="h-3 w-6 shrink-0 rounded bg-muted-foreground/20 sm:w-7" /> : null}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex h-7 items-center">
|
||||
<div className="h-3.5 w-48 max-w-[70%] rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
<div className="mt-1 flex h-5 items-center">
|
||||
<div className="h-3 w-32 max-w-[55%] rounded bg-muted-foreground/20 opacity-60" />
|
||||
</div>
|
||||
{providers.map((source) => (
|
||||
<section key={source} className={grouped ? "space-y-1" : undefined}>
|
||||
{grouped ? <div className="flex items-center justify-between px-5 py-1.5">
|
||||
<ProviderMark provider={source} />
|
||||
<div className="h-3.5 w-3.5 rounded bg-muted-foreground/20" />
|
||||
</div> : null}
|
||||
<div className="space-y-1 px-3 pb-3 sm:px-4">
|
||||
{Array.from({ length: 5 }, (_, index) => (
|
||||
<div key={index} className="flex min-w-0 items-center gap-2 px-1 py-3.5 sm:gap-3 sm:px-2">
|
||||
{ranked ? <div className="h-3 w-6 shrink-0 rounded bg-muted-foreground/20 sm:w-7" /> : null}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex h-7 items-center">
|
||||
<div className="h-3.5 w-48 max-w-[70%] rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
<div className="mt-1 flex h-[1.5em] items-center text-[12px]">
|
||||
<div className="h-3 w-32 max-w-[55%] rounded bg-muted-foreground/20 opacity-60" />
|
||||
</div>
|
||||
</div>
|
||||
{source === "skills_sh" ? <div className="hidden h-[30px] w-24 shrink-0 rounded bg-muted-foreground/10 sm:block" /> : null}
|
||||
<div className="h-9 w-9 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="h-9 w-9 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</SkeletonStatus>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function CatalogSkeleton({ label, layout }: {
|
||||
export function CatalogSkeleton({ label, layout, appActionLabel }: {
|
||||
label: string;
|
||||
layout: "apps" | "channels" | "skills";
|
||||
appActionLabel?: string;
|
||||
}) {
|
||||
const channels = layout === "channels";
|
||||
const skills = layout === "skills";
|
||||
@@ -18,20 +19,36 @@ export function CatalogSkeleton({ label, layout }: {
|
||||
channels && "gap-x-4 min-[640px]:grid-cols-2",
|
||||
)}
|
||||
>
|
||||
{skills ? (
|
||||
<div className="flex h-8 items-center gap-2 px-2 py-1.5">
|
||||
<div className={cn(block, "h-3 w-16")} />
|
||||
<div className={cn(block, "h-3 w-3 opacity-60")} />
|
||||
</div>
|
||||
) : null}
|
||||
{Array.from({ length: 6 }, (_, index) => (
|
||||
<div key={index} className={cn(
|
||||
"flex min-w-0 items-center gap-3",
|
||||
channels ? "settings-list-row py-2.5" : skills ? "px-2 py-3" : "px-3 py-3",
|
||||
appActionLabel && "flex-wrap gap-x-3 gap-y-2",
|
||||
)}>
|
||||
<div className={cn(block, "shrink-0", skills
|
||||
? "h-1.5 w-1.5 rounded-full" : "h-9 w-9 rounded-[10px]")} />
|
||||
<div className="min-w-0 flex-1 py-1">
|
||||
<div className={cn(block, "h-3.5", index % 2 ? "w-1/2" : "w-2/3")} />
|
||||
{!channels ? <div className={cn(block, "mt-2 h-3 w-4/5 opacity-60")} /> : null}
|
||||
? "h-1.5 w-1.5 rounded-full" : channels ? "h-8 w-8 rounded-[9px]" : "h-9 w-9 rounded-[10px]")} />
|
||||
<div className={cn("min-w-0 flex-1", appActionLabel && "min-w-[8rem] flex-[1_1_8rem]")}>
|
||||
<div className="flex h-5 items-center">
|
||||
<div className={cn(block, "h-3.5", index % 2 ? "w-1/2" : "w-2/3")} />
|
||||
</div>
|
||||
{!channels ? <div className="mt-0.5 flex h-5 items-center">
|
||||
<div className={cn(block, "h-3 w-4/5 opacity-60")} />
|
||||
</div> : null}
|
||||
</div>
|
||||
<div className={cn("flex shrink-0 items-center justify-center", channels && "w-16")}>
|
||||
<div className={cn(block, channels ? "h-[22px] w-[38px] rounded-full"
|
||||
: skills ? "hidden h-3 w-20 sm:block" : "h-7 w-7 rounded-full")} />
|
||||
<div className={cn("flex shrink-0 items-center justify-center",
|
||||
channels && "w-16", skills && "hidden h-[16.5px] w-[92px] justify-end sm:flex",
|
||||
appActionLabel && "ml-auto")}>
|
||||
{appActionLabel ? <div className={cn(block, "flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-semibold")}>
|
||||
<span className="h-4 w-4 shrink-0" />
|
||||
<span className="invisible">{appActionLabel}</span>
|
||||
</div> : <div className={cn(block, channels ? "h-5 w-[38px] rounded-full"
|
||||
: skills ? "h-3 w-20" : "h-9 w-9 rounded-full")} />}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -505,15 +505,20 @@ export function ModelIdPicker({
|
||||
) : loading ? (
|
||||
<SkeletonStatus
|
||||
label={tx("settings.models.loadingModels", "Loading models...")}
|
||||
className="space-y-0.5 py-1"
|
||||
className="text-[12px]"
|
||||
>
|
||||
{["w-3/5", "w-4/5", "w-1/2"].map((width) => (
|
||||
<div key={width} className="flex items-center gap-2 px-2 py-1.5">
|
||||
<div className="h-3.5 w-3.5 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
<div key={width} className="flex items-center justify-between gap-2 px-2 py-1.5">
|
||||
<div className="h-5 w-5 shrink-0 rounded-md bg-muted-foreground/20" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className={cn("h-3 rounded bg-muted-foreground/20", width)} />
|
||||
<div className="mt-1.5 h-2.5 w-2/5 rounded bg-muted-foreground/10" />
|
||||
<div className="flex h-[1.5em] items-center">
|
||||
<div className={cn("h-3 rounded bg-muted-foreground/20", width)} />
|
||||
</div>
|
||||
{providerHasManagedModels ? <div className="mt-0.5 flex h-[1.5em] items-center text-[10.5px]">
|
||||
<div className="h-2.5 w-2/5 rounded bg-muted-foreground/10" />
|
||||
</div> : null}
|
||||
</div>
|
||||
<div className="ml-2 h-2.5 w-7 shrink-0 rounded bg-muted-foreground/10" />
|
||||
</div>
|
||||
))}
|
||||
</SkeletonStatus>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
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" | "segments" | "theme" | "edit" | "text" | "feature";
|
||||
const block = "rounded bg-muted-foreground/20";
|
||||
|
||||
function Title({ heading = false }: { heading?: boolean }) {
|
||||
return <div className={cn("settings-section-title flex h-5 items-center", heading && "!m-0 !p-0")}>
|
||||
<div className={cn(block, "h-3 w-24")} />
|
||||
</div>;
|
||||
}
|
||||
|
||||
function Row({ control }: { control: Control }) {
|
||||
const toggle = control === "switch" || control === "feature";
|
||||
return <div data-settings-skeleton-row className="settings-row">
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-32 max-w-full")} /></div>
|
||||
<div className="settings-control">
|
||||
{control === "feature" ? <div className={cn(block, "mr-3 h-3 w-14")} /> : null}
|
||||
{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-[38px] shrink-0 rounded-full" : control === "input" ? "h-9 w-full rounded-full"
|
||||
: control === "segments" || control === "theme" ? "segmented-control w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[19.5px] w-24",
|
||||
control === "segments" && "h-[34px]", control === "theme" && "h-8",
|
||||
)} />}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function Group({ controls }: { controls: Control[] }) {
|
||||
return <section><Title /><SettingsGroup>{controls.map((control, index) => <Row key={index} control={control} />)}</SettingsGroup></section>;
|
||||
}
|
||||
|
||||
function RuntimeGroups({ page }: { page: RuntimeConfigPage }) {
|
||||
return <>{RUNTIME_CONFIG_GROUPS.filter((group) => group.page === page).map((group) => group.id === "chat"
|
||||
? <Group key={group.id} controls={["switch", "segments"]} />
|
||||
: <Group key={group.id} controls={RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group.id && (!field.when || field.when.value === true)).map((field) =>
|
||||
field.kind === "boolean" || field.kind === "toggle" ? "switch" : field.kind === "list" ? "edit" : field.kind === "duration" ? "duration" : "input",
|
||||
)} />)}</>;
|
||||
}
|
||||
|
||||
export function SettingsSectionSkeleton({ section, showRestart = false }: { section: SettingsSectionKey; showRestart?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
let content: ReactNode = null;
|
||||
if (isCapabilitySection(section)) content = <>
|
||||
<div className="settings-section-heading"><Title heading /></div>
|
||||
{[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={["segments", "segments", "switch", "switch", "switch", "switch"]} /></>;
|
||||
break;
|
||||
case "overview":
|
||||
content = <>
|
||||
<section className="rounded-panel bg-settings-surface p-6">
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-24")} /></div>
|
||||
<div className="mt-2 flex h-9 items-center"><div className={cn(block, "h-7 w-20")} /></div>
|
||||
<div className="mt-5 flex h-7 items-center"><div className={cn(block, "h-3.5 w-3/5")} /></div>
|
||||
</section>
|
||||
{[1, 3].map((count) => <section key={count}><Title /><SettingsGroup>{Array.from({ length: count }, (_, index) =>
|
||||
<div key={index} data-overview-skeleton-row className="flex min-h-[68px] items-center gap-3 px-4 py-3.5 sm:px-5">
|
||||
<div className={cn(block, "h-9 w-9 shrink-0 rounded-control")} /><div className={cn(block, "h-3.5 w-28")} />
|
||||
<div className={cn(block, "ml-auto h-3 w-20")} /><div className="h-4 w-4" />
|
||||
</div>,
|
||||
)}</SettingsGroup></section>)}
|
||||
</>;
|
||||
break;
|
||||
case "models":
|
||||
content = <section><Title /><SettingsGroup>
|
||||
<div data-model-preset-skeleton className="settings-list-inset grid grid-cols-[auto_minmax(0,1fr)_auto_auto_auto] items-center gap-x-3 py-5 sm:py-6">
|
||||
<div className={cn(block, "h-[54.25px] w-[54.25px] shrink-0 rounded-control sm:h-[59.75px] sm:w-[59.75px]")} />
|
||||
<div className="min-w-0"><div className="flex h-[30.25px] items-center sm:h-[35.75px]"><div className={cn(block, "h-4 w-2/3 sm:h-5")} /></div><div className="mt-1 flex h-5 items-center"><div className={cn(block, "h-3 w-4/5 opacity-60")} /></div></div>
|
||||
<div className="text-[13px]"><span className="invisible hidden sm:inline">{t("settings.configure")}</span><div className="h-4 w-4 sm:hidden" /></div>
|
||||
<div className="h-4 w-4" /><div className={cn(block, "h-5 w-[38px] shrink-0 rounded-full")} />
|
||||
</div>
|
||||
</SettingsGroup><div className="settings-footer flex items-center justify-between gap-2"><div className="flex h-11 items-center sm:h-9"><div className={cn(block, "h-3 w-20")} /></div><div className="flex h-11 items-center sm:h-9"><div className={cn(block, "h-3 w-28")} /></div></div></section>;
|
||||
break;
|
||||
case "runtime":
|
||||
content = <><RuntimeGroups page="runtime" /><Group controls={["input", "segments", "input", "input"]} /><Group controls={["input"]} /><Group controls={showRestart ? ["text", "text", "input"] : ["text", "text"]} /></>;
|
||||
break;
|
||||
case "advanced":
|
||||
content = <RuntimeGroups page="advanced" />;
|
||||
break;
|
||||
case "about":
|
||||
content = <>
|
||||
<div className="flex flex-col items-center gap-4 py-6">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16" />
|
||||
<img src="/brand/nanobot_wordmark.svg" alt="" className="h-auto w-40 dark:brightness-150" />
|
||||
<div className="flex flex-col items-center gap-4"><div className="mt-0.5 flex h-5 items-center"><div className={cn(block, "h-3 w-20")} /></div><div className={cn(block, "h-9 w-36 rounded-full")} /></div>
|
||||
</div>
|
||||
<SettingsGroup>{[0, 1, 2].map((index) => <div key={index} className="settings-list-row flex items-center gap-3"><div className={cn(block, "h-4 w-4")} /><div className={cn(block, "h-3.5 w-28")} /></div>)}</SettingsGroup>
|
||||
</>;
|
||||
break;
|
||||
}
|
||||
return <SkeletonStatus label={t("settings.status.loading")} className="settings-stack">{content}</SkeletonStatus>;
|
||||
}
|
||||
@@ -348,7 +348,8 @@ export function AppsCatalogSettings({
|
||||
</div>
|
||||
) : null}
|
||||
{loading ? (
|
||||
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps" />
|
||||
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps"
|
||||
appActionLabel={filter === "cli" ? undefined : tx("settings.mcp.manage", "Manage")} />
|
||||
) : !items.length && !statusIsError ? (
|
||||
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
|
||||
<p>{emptyTitle}</p>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { CircleAlert, Loader2, X } from "lucide-react";
|
||||
import { useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
|
||||
import type { AutomationRunRecord } from "@/components/settings/system/AutomationRunDialogView";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
@@ -40,6 +41,7 @@ export interface AutomationCalendarRunProps {
|
||||
|
||||
interface AutomationCalendarProps {
|
||||
jobs: SessionAutomationJob[];
|
||||
loadingLabel?: string;
|
||||
month: Date;
|
||||
locale: string;
|
||||
copy: CalendarCopy;
|
||||
@@ -226,7 +228,7 @@ function CalendarOverflowEntries({ entries, dayLabel, locale, copy, onInspect }:
|
||||
);
|
||||
}
|
||||
|
||||
export function AutomationCalendar({ jobs, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
|
||||
export function AutomationCalendar({ jobs, loadingLabel, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
|
||||
const calendarRef = useRef<HTMLElement | null>(null);
|
||||
const runTrigger = useRef<HTMLElement | null>(null);
|
||||
const [selectedRun, setSelectedRun] = useState<{ job: SessionAutomationJob; run: AutomationRunRecord } | null>(null);
|
||||
@@ -273,8 +275,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
|
||||
const content = <>
|
||||
<div className="automation-calendar-header bg-foreground/[0.025]">
|
||||
{wideCalendar ? <div className="automation-calendar-weekdays" aria-hidden>
|
||||
{weekdayLabels.map((label) => <div key={label}>{label}</div>)}
|
||||
@@ -307,6 +308,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
</time>
|
||||
</div>
|
||||
<div className="space-y-0.5 px-1 pb-1">
|
||||
{loadingLabel ? <div className="flex h-7 items-center px-2"><div className="h-2.5 w-3/4 rounded bg-muted-foreground/15" /></div> : null}
|
||||
{entries.slice(0, 3).map((entry) => (
|
||||
<CalendarEntryRow
|
||||
key={entry.id}
|
||||
@@ -333,7 +335,15 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
</div> : null}
|
||||
|
||||
{!wideCalendar ? <div className="automation-calendar-agenda px-3 py-2 sm:px-4">
|
||||
{visibleEntries.length ? (
|
||||
{loadingLabel ? <div>
|
||||
{[0, 1, 2].map((index) => <div key={index} data-agenda-skeleton-row className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
|
||||
<div className="pt-2"><div className="mt-1 h-2.5 w-16 rounded bg-muted-foreground/15" /></div>
|
||||
<div className="px-2 py-2">
|
||||
<div className="flex h-4 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="mt-1 flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
|
||||
</div>
|
||||
</div>)}
|
||||
</div> : visibleEntries.length ? (
|
||||
<ol>
|
||||
{days.filter((day) => entriesByDay.has(dateKey(day))).map((day) => (
|
||||
<li key={dateKey(day)} className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
|
||||
@@ -357,7 +367,11 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
<div className="flex min-h-28 items-center justify-center text-[13px] text-muted-foreground">{copy.noEntries}</div>
|
||||
)}
|
||||
</div> : null}
|
||||
</>;
|
||||
|
||||
return (
|
||||
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
|
||||
{loadingLabel ? <SkeletonStatus label={loadingLabel} className="">{content}</SkeletonStatus> : content}
|
||||
{selectedRun ? renderRunDialog({
|
||||
job: selectedRun.job, run: selectedRun.run, locale, open: runOpen,
|
||||
onOpenChange: setRunOpen,
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { channelTranslator } from "@/channel-plugins/i18n";
|
||||
import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { AutomationCalendar } from "@/components/settings/system/AutomationCalendar";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { AutomationRunDialog } from "@/components/settings/system/AutomationRunDialog";
|
||||
import { AutomationChatBinding, type AutomationChatNames, type ChangeAutomationChat } from "@/components/settings/system/AutomationChatBinding";
|
||||
import { AutomationRunAtPicker, parseAutomationRunAt } from "@/components/settings/system/AutomationRunAtPicker";
|
||||
@@ -283,7 +284,7 @@ export function AutomationsSettings({
|
||||
{new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month)}
|
||||
</h2>
|
||||
) : null}
|
||||
{filters ? <div className="automation-panel-filters min-w-0">{filters}</div> : null}
|
||||
{filters || (loading && !payload) ? <div className="automation-panel-filters min-w-0">{filters ?? <div className="h-8 w-8" aria-hidden />}</div> : null}
|
||||
{view === "calendar" ? (
|
||||
<div className="automation-calendar-navigation flex shrink-0 items-center gap-1">
|
||||
<Button type="button" variant="ghost" size="sm" className="h-8 rounded-full bg-background/60 px-3 text-[12px] text-foreground"
|
||||
@@ -303,11 +304,13 @@ export function AutomationsSettings({
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{loading && !payload ? (
|
||||
<div role="status" className="flex h-44 items-center justify-center rounded-panel border border-border/70 bg-[hsl(var(--settings-surface))] text-[13px] text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{tx("settings.automations.loading", "Loading automations...")}
|
||||
</div>
|
||||
{view === "tasks" && loading && !payload ? (
|
||||
<SkeletonStatus label={tx("settings.automations.loading", "Loading automations...")} className="space-y-1 p-1">
|
||||
{[0, 1, 2].map((index) => <div key={index} data-automation-task-skeleton className="px-3 py-3">
|
||||
<div className="flex h-[21px] items-center"><div className="h-3.5 w-2/5 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="mt-1 flex h-5 items-center"><div className="h-3 w-1/4 rounded bg-muted-foreground/15" /></div>
|
||||
</div>)}
|
||||
</SkeletonStatus>
|
||||
) : view === "tasks" ? (
|
||||
<section className="p-1" aria-label={tx("settings.automations.views.tasks", "Tasks")}>
|
||||
{filtered.length ? (
|
||||
@@ -352,6 +355,7 @@ export function AutomationsSettings({
|
||||
<AutomationCalendar
|
||||
renderRunDialog={(props) => <AutomationRunDialog token={token} {...props} />}
|
||||
jobs={filtered}
|
||||
loadingLabel={loading && !payload ? tx("settings.automations.loading", "Loading automations...") : undefined}
|
||||
month={month}
|
||||
locale={locale}
|
||||
copy={{
|
||||
|
||||
@@ -369,10 +369,17 @@ function ToolsPanel({
|
||||
<SkeletonStatus label={tx("settings.mcp.loadingTools", "Loading tools…")} className="space-y-4">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<div className="h-10 min-w-0 rounded-full bg-muted-foreground/20 sm:flex-1" />
|
||||
<div className="flex h-8 items-center justify-between gap-4 sm:justify-end">
|
||||
<div className="mr-auto h-3 w-20 rounded bg-muted-foreground/20 sm:mr-1" />
|
||||
<div className="h-3 w-6 rounded bg-muted-foreground/20" />
|
||||
<div className="h-3 w-9 rounded bg-muted-foreground/20" />
|
||||
<div className="flex items-center justify-between gap-2 sm:justify-end">
|
||||
<div className="relative mr-auto text-[13px] tabular-nums sm:mr-1">
|
||||
<span className="invisible">{tx("settings.mcp.selectedCount", "{{count}} selected").replace("{{count}}", String(selectedToolCount))}</span>
|
||||
<div className="absolute inset-x-0 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
{[tx("settings.mcp.allTools", "All"), tx("settings.mcp.noTools", "None")].map((label) => (
|
||||
<div key={label} className="relative flex h-8 items-center px-2.5 text-[12.5px] font-semibold">
|
||||
<span className="invisible">{label}</span>
|
||||
<div className="absolute inset-x-2.5 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-hidden rounded-floating border border-border/55">
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useSystemSettingsState() {
|
||||
const [cliAppsLoading, setCliAppsLoading] = useState(true);
|
||||
const [nanobotFeaturesLoading, setNanobotFeaturesLoading] = useState(true);
|
||||
const [mcpPresetsLoading, setMcpPresetsLoading] = useState(true);
|
||||
const [automationsLoading, setAutomationsLoading] = useState(false);
|
||||
const [automationsLoading, setAutomationsLoading] = useState(true);
|
||||
const [cliAppsAction, setCliAppsAction] = useState<string | null>(null);
|
||||
const [nanobotFeatureAction, setNanobotFeatureAction] = useState<string | null>(null);
|
||||
const nanobotFeatureActionRef = useRef<string | null>(null);
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/* Critical first-paint styles are inlined by Vite and shared by StartupSkeleton. */
|
||||
.startup-shell { --startup-fill: hsl(240 4% 40% / .2); --startup-surface: hsl(60 6% 96.7%); --startup-nav: hsl(40 8% 96.8%); display: flex; width: 100%; height: 100%; overflow: hidden; }
|
||||
html.dark .startup-shell { --startup-fill: hsl(0 0% 72% / .2); --startup-surface: hsl(0 0% 22%); --startup-nav: hsl(0 0% 22%); }
|
||||
.startup-shell, .startup-shell * { box-sizing: border-box; }
|
||||
.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; }
|
||||
.startup-block { height: 14px; border-radius: 4px; background: var(--startup-fill); }
|
||||
.startup-navigation { display: none; flex: 0 0 var(--startup-sidebar-width); padding: 20px 12px; background: var(--startup-nav); overflow: hidden; }
|
||||
.startup-nav-brand { width: 32px; height: 32px; margin-bottom: 28px; border-radius: 10px; }
|
||||
.startup-nav-row { display: flex; height: 40px; align-items: center; gap: 12px; padding: 0 8px; }
|
||||
.startup-nav-icon { flex: 0 0 16px; height: 16px; }
|
||||
.startup-nav-label { width: 96px; height: 12px; }
|
||||
.startup-content { flex: 1; min-width: 0; height: 100%; }
|
||||
.startup-scroll { height: 100%; overflow-y: auto; scrollbar-gutter: stable; scrollbar-width: thin; }
|
||||
.startup-page { width: 100%; max-width: 816px; padding: 24px 12px; margin: 0 auto; }
|
||||
.startup-page-header { margin-bottom: 28px; }
|
||||
.startup-back { display: flex; align-items: center; height: 30px; margin-bottom: 16px; padding-left: 10px; }
|
||||
@media (pointer: coarse) { .startup-back { height: 44px; } }
|
||||
.startup-back .startup-block { width: 96px; height: 12px; }
|
||||
.startup-title { display: flex; align-items: center; height: 30px; }
|
||||
.startup-title .startup-block { width: 112px; height: 24px; }
|
||||
.startup-tabs { display: none; height: 35.5px; margin-bottom: 20px; }
|
||||
.startup-tabs .startup-block { width: 174px; height: 100%; border-radius: 9999px; }
|
||||
.startup-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
|
||||
.startup-search { flex: 1; height: 48px; min-height: 48px; border-radius: 9999px; }
|
||||
.startup-filters { width: 100%; height: 34px; border-radius: 9999px; }
|
||||
.startup-catalog-heading { display: none; height: 29px; align-items: start; padding: 3px 16px 8px; border-bottom: 1px solid var(--startup-fill); }
|
||||
.startup-catalog-heading .startup-block { width: 40px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-frame { padding: 12px; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-heading { display: flex; }
|
||||
.startup-catalog { display: grid; gap: 4px; padding: 12px 0; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-catalog-group { display: none; align-items: center; height: 32px; padding: 0 8px; }
|
||||
.startup-catalog-group .startup-block { width: 64px; height: 12px; }
|
||||
.startup-catalog-row { display: flex; min-width: 0; align-items: center; gap: 12px; height: 66px; padding: 12px; }
|
||||
.startup-catalog-icon { flex: 0 0 36px; height: 36px; border-radius: 10px; }
|
||||
.startup-catalog-copy { flex: 1; min-width: 0; }
|
||||
.startup-catalog-copy .startup-block:first-child { width: 66.6667%; margin: 3px 0 5.5px; }
|
||||
.startup-catalog-copy .startup-block + .startup-block { width: 80%; height: 12px; opacity: .6; margin: 4px 0; }
|
||||
.startup-catalog-action { flex: 0 0 36px; height: 36px; border-radius: 9999px; }
|
||||
.startup-catalog-row:nth-child(odd) .startup-catalog-copy .startup-block:first-child { width: 50%; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-tabs { display: block; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-panel { overflow: hidden; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-toolbar { padding: 16px 16px 8px; margin: 0; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-search { height: 36px; min-height: 36px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-filters { height: 32.5px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog { display: block; padding: 8px 12px 12px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-group { display: flex; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-row { margin-top: 4px; padding-inline: 8px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-icon { flex-basis: 6px; height: 6px; border-radius: 100%; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-action { display: none; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog { padding: 0; column-gap: 16px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-row { height: 60px; padding: 10px 16px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-icon { flex-basis: 32px; height: 32px; border-radius: 9px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-action { flex-basis: 38px; height: 20px; margin-inline: 13px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-copy .startup-block + .startup-block { display: none; }
|
||||
.startup-automation, .startup-settings, .startup-chat { display: none; }
|
||||
.startup-shell:is([data-startup-surface="automations"], [data-startup-surface="settings"], [data-startup-surface="remote"]) .startup-panel { display: none; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-page { max-width: 984px; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-automation { display: block; }
|
||||
.startup-automation-composer { display: flex; align-items: center; height: 110px; margin-bottom: 20px; padding: 16px; border: 1px solid var(--startup-fill); border-radius: 28px; }
|
||||
.startup-automation-composer .startup-block { width: 60%; }
|
||||
.startup-calendar { background: var(--startup-surface); border-radius: 22px; overflow: hidden; container-type: inline-size; }
|
||||
.startup-calendar-toolbar { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; min-height: 64px; padding: 12px; }
|
||||
.startup-calendar-toolbar .startup-block { width: 156px; height: 40px; border-radius: 16px; }
|
||||
.startup-calendar-toolbar .startup-block + .startup-block { width: 100px; height: 12px; }
|
||||
.startup-calendar-toolbar .startup-block.startup-calendar-navigation { flex: 0 0 130px; height: 32px; }
|
||||
.startup-calendar-days { padding: 8px 12px; }
|
||||
.startup-calendar-days > div { display: none; align-items: center; height: 72px; }
|
||||
.startup-calendar-days > div:nth-child(-n+3) { display: flex; }
|
||||
.startup-calendar-days .startup-block { width: 55%; }
|
||||
@container (min-width: 704px) {
|
||||
.startup-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 32px 0 0; }
|
||||
.startup-calendar-days > div, .startup-calendar-days > div:nth-child(-n+3) { display: flex; align-items: start; height: 112px; padding: 12px; border-top: 1px solid var(--startup-fill); border-right: 1px solid var(--startup-fill); }
|
||||
.startup-calendar-days .startup-block { width: 18px; height: 10px; margin-left: auto; }
|
||||
.startup-shell[data-calendar-weeks="4"] .startup-calendar-days > div:nth-child(n+29),
|
||||
.startup-shell[data-calendar-weeks="5"] .startup-calendar-days > div:nth-child(n+36) { display: none; }
|
||||
}
|
||||
.startup-shell:is([data-startup-surface="settings"], [data-startup-surface="remote"]) .startup-settings { display: block; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page { max-width: 720px; padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page-header { display: none; }
|
||||
.startup-settings-group + .startup-settings-group { margin-top: 20px; }
|
||||
.startup-settings-title { width: 96px; height: 12px; margin: 4px 16px 24px; }
|
||||
.startup-settings-row { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 12px 16px; gap: 24px; background: var(--startup-surface); }
|
||||
.startup-settings-row:nth-child(2) { border-radius: 22px 22px 0 0; }
|
||||
.startup-settings-row:last-child { border-radius: 0 0 22px 22px; }
|
||||
.startup-settings-row .startup-block { width: 128px; }
|
||||
.startup-settings-row .startup-block + .startup-block { width: 38px; height: 20px; border-radius: 9999px; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-scroll { display: none; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-content { container: startup-chat / inline-size; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-chat { position: relative; display: flex; flex-direction: column; height: 100%; }
|
||||
.startup-chat-header { z-index: 1; display: flex; flex: 0 0 44px; width: 100%; align-items: center; justify-content: space-between; padding: 4px 12px; }
|
||||
.startup-header-leading, .startup-header-actions { display: flex; align-items: center; gap: 2px; padding: 1px; }
|
||||
.startup-header-menu, .startup-header-actions > div { display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; }
|
||||
.startup-chat-header .startup-block { width: 14px; height: 14px; }
|
||||
.startup-chat-header .startup-header-title { display: none; }
|
||||
.startup-chat-viewport { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
|
||||
/* Match ThreadViewport's hero grid: mobile docks the composer, desktop balances its trailing row. */
|
||||
.startup-chat-layout { display: grid; grid-template-rows: minmax(min-content, 1fr) auto 0fr; width: 100%; max-width: 1152px; min-height: 100%; margin: 0 auto; padding: 24px 12px calc(12px + env(safe-area-inset-bottom)); }
|
||||
.startup-messages { display: none; width: 100%; max-width: 816px; margin: 24px auto; padding: 0 20px; }
|
||||
.startup-messages .startup-block { width: 70%; margin-bottom: 20px; }
|
||||
.startup-messages .startup-block:first-child { width: 40%; margin-left: auto; height: 40px; border-radius: 20px; }
|
||||
.startup-messages .startup-block:last-child { width: 50%; }
|
||||
.startup-welcome { display: flex; min-height: 0; align-items: center; justify-content: center; }
|
||||
.startup-welcome-line { display: flex; width: 100%; max-width: 704px; height: 36.72px; align-items: center; justify-content: center; }
|
||||
.startup-welcome-line .startup-block { width: 60%; height: 24px; }
|
||||
.startup-composer { container: startup-composer / inline-size; width: 100%; max-width: 928px; margin: 0 auto; }
|
||||
.startup-composer-surface { overflow: hidden; border-radius: 28px; background: hsl(0 0% 96.1% / .8); }
|
||||
html.dark .startup-composer-surface { background: hsl(0 0% 22%); }
|
||||
.startup-composer-input { display: flex; align-items: start; height: 78px; padding: 27px 16px 8px; }
|
||||
.startup-composer-input .startup-block { width: 45%; height: 14px; margin-top: 5px; }
|
||||
.startup-composer-footer { display: flex; align-items: center; gap: 6px; padding: 0 12px 14px; }
|
||||
.startup-composer-primary, .startup-composer-actions { display: flex; align-items: center; gap: 6px; height: 32px; }
|
||||
.startup-composer-primary { flex: 1; min-width: 0; }
|
||||
.startup-composer-actions { flex-shrink: 0; }
|
||||
.startup-attach, .startup-send { flex: 0 0 32px; height: 32px; border-radius: 50%; }
|
||||
.startup-workspace { width: 112px; }
|
||||
.startup-access { width: 88px; }
|
||||
.startup-model { width: 88px; }
|
||||
.startup-mobile-model, .startup-workspace-row { display: none; }
|
||||
.startup-chat-spacer { min-height: 0; }
|
||||
@container startup-chat (width > 1152px) { .startup-chat-header { position: absolute; inset: 0 0 auto; height: 44px; } }
|
||||
.startup-shell[data-existing-chat="true"] .startup-header-title { display: block; width: 96px; height: 12px; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-chat-layout { display: flex; flex-direction: column; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-messages { display: block; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-composer { max-width: 792px; margin-top: auto; }
|
||||
.startup-shell[data-existing-chat="true"] :is(.startup-welcome, .startup-workspace-row) { display: none; }
|
||||
@media (min-width: 640px) {
|
||||
.startup-chat-layout { grid-template-rows: minmax(min-content, 1fr) auto 1fr; padding: 48px 16px; }
|
||||
.startup-welcome { align-items: end; padding-bottom: 32px; }
|
||||
.startup-welcome-line { height: 60px; }
|
||||
.startup-welcome-line .startup-block { height: 36px; }
|
||||
.startup-composer-input { padding-inline: 20px; }
|
||||
.startup-composer-footer { padding-inline: 16px; }
|
||||
.startup-page { max-width: 824px; padding: 32px 16px; }
|
||||
.startup-title { height: 35px; }
|
||||
.startup-toolbar { flex-direction: row; align-items: center; }
|
||||
.startup-filters { width: 174px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-toolbar { flex-direction: column; align-items: stretch; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-filters { width: 100%; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-frame { padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-filters { width: 233px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-search { max-width: 320px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-toolbar { justify-content: space-between; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog { padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-action { display: block; flex-basis: 80px; height: 12px; margin-left: 12px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page { padding-inline: 32px; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-page { max-width: 992px; }
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.startup-header-menu { display: none; }
|
||||
.startup-navigation { display: block; }
|
||||
.startup-shell[data-embedded="true"] .startup-navigation { display: none; }
|
||||
.startup-shell[data-sidebar-expanded="false"] .startup-nav-label { display: none; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-navigation { flex-basis: 192px; background: var(--startup-surface); }
|
||||
.startup-page { padding-top: 48px; }
|
||||
.startup-back { display: none; }
|
||||
.startup-shell[data-sidebar-expanded="true"]:not([data-startup-surface="settings"]) .startup-page-header { display: none; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-toolbar { flex-direction: row; align-items: center; }
|
||||
.startup-shell[data-startup-surface="apps"][data-sidebar-expanded="true"] .startup-toolbar { margin-top: 20px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-filters { width: 156px; }
|
||||
.startup-automation-composer { height: 62px; }
|
||||
}
|
||||
@media (min-width: 1280px) {
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
|
||||
}
|
||||
@container startup-composer (max-width: 512px) {
|
||||
.startup-composer-input { height: 52px; padding: 12px 16px 8px; }
|
||||
.startup-composer-footer { gap: 4px; padding: 0 8px 8px; }
|
||||
.startup-composer-primary, .startup-composer-actions { gap: 4px; height: 44px; }
|
||||
.startup-attach, .startup-send { flex-basis: 36px; height: 36px; margin: 4px; }
|
||||
.startup-workspace, .startup-access, .startup-model { display: none; }
|
||||
.startup-mobile-model { display: block; width: 80px; }
|
||||
.startup-workspace-row { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 6px 12px; background: hsl(0 0% 96.1% / .45); }
|
||||
.startup-workspace-row .startup-block { width: 112px; }
|
||||
.startup-workspace-row .startup-block + .startup-block { width: 88px; }
|
||||
html.dark .startup-workspace-row { background: hsl(0 0% 100% / .045); }
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
CalendarClock,
|
||||
ChevronRight,
|
||||
CircleAlert,
|
||||
RefreshCcw,
|
||||
} from "lucide-react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
} from "@/components/settings/system/AutomationsSettings";
|
||||
import type { AutomationAction } from "@/components/settings/system/AutomationsSettings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||
import {
|
||||
Popover,
|
||||
@@ -112,12 +112,18 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
|
||||
setActionKey(null);
|
||||
}
|
||||
};
|
||||
const automationContent = loading ? (
|
||||
<div className="mx-2 flex items-center gap-2 rounded-floating bg-muted/45 px-3 py-3 text-[12.5px] text-muted-foreground">
|
||||
<RefreshCcw className="h-3.5 w-3.5 animate-spin" />
|
||||
{t("thread.sessionInfo.loading")}
|
||||
</div>
|
||||
) : loadFailed ? (
|
||||
const automationContent = loading && jobs.length === 0 ? (
|
||||
<SkeletonStatus label={t("thread.sessionInfo.loading")} className="space-y-1 px-2">
|
||||
{[0, 1, 2].map((index) => <div key={index} data-session-job-skeleton className="grid min-h-12 grid-cols-[0.375rem_minmax(0,1fr)_1rem] items-center gap-2.5 px-3 py-2">
|
||||
<div className="h-1.5 w-1.5 rounded-full bg-muted-foreground/20" />
|
||||
<div className="min-w-0">
|
||||
<div className="flex h-5 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
|
||||
</div>
|
||||
<div className="h-4 w-4" />
|
||||
</div>)}
|
||||
</SkeletonStatus>
|
||||
) : loadFailed && jobs.length === 0 ? (
|
||||
<div className="mx-2 flex items-center gap-2 rounded-floating bg-destructive/10 px-3 py-3 text-[12.5px] text-destructive">
|
||||
<CircleAlert className="h-3.5 w-3.5" />
|
||||
{t("thread.sessionInfo.loadFailed")}
|
||||
@@ -175,7 +181,7 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
|
||||
{t("thread.sessionInfo.automations")}
|
||||
</span>
|
||||
<span className="rounded-full bg-muted/70 px-2 py-0.5 text-[11px] tabular-nums text-muted-foreground">
|
||||
{t("thread.sessionInfo.count", { count: jobs.length })}
|
||||
{loading && jobs.length === 0 ? "—" : t("thread.sessionInfo.count", { count: jobs.length })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -121,7 +121,7 @@ function WorkspaceDirectorySkeleton() {
|
||||
useLayoutEffect(() => {
|
||||
const viewport = viewportRef.current;
|
||||
if (!viewport) return;
|
||||
const measure = () => setRows(Math.max(1, Math.ceil(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
|
||||
const measure = () => setRows(Math.max(1, Math.floor(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
|
||||
measure();
|
||||
const observer = new ResizeObserver(measure);
|
||||
observer.observe(viewport);
|
||||
@@ -129,7 +129,7 @@ function WorkspaceDirectorySkeleton() {
|
||||
}, []);
|
||||
const widths = ["64%", "78%", "52%", "70%", "60%", "74%"];
|
||||
return (
|
||||
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading h-full">
|
||||
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading flex h-full flex-col justify-center">
|
||||
<span className="sr-only">{t("workspace.picker.loading")}</span>
|
||||
<div aria-hidden="true">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
@@ -636,7 +636,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
|
||||
<div className={cn("mr-[var(--picker-toolbar-inset)] flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[var(--picker-field-radius)] bg-[#fcfcfc] dark:bg-muted", compact && showLocations && canBrowse && "hidden")}>
|
||||
<div ref={attachColumns} data-workspace-columns className="sidebar-scrollbar flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain">
|
||||
{columns.map((column, columnIndex) => (!compact || columnIndex === currentColumnIndex) && <WorkspaceDirectoryColumn key={columnIndex} options={column.options} selectedPath={column.selectedPath} initialScrollTop={previewingPath ? 0 : currentVisit.scrollTops[columnIndex] ?? 0} visitRevision={history.revision} activeIndex={highlightActive && columnIndex === activeColumn ? activeOption : null}
|
||||
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
|
||||
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none [scrollbar-gutter:stable] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
|
||||
onFocus={event => { if (event.target === event.currentTarget) { setActiveColumn(columnIndex); setActiveIndex(0); } }}
|
||||
onKeyDown={event => {
|
||||
if (event.target !== event.currentTarget || event.altKey || event.metaKey || event.ctrlKey || pickingFolder) return;
|
||||
|
||||
@@ -1459,12 +1459,12 @@
|
||||
.settings-footer-auto { min-block-size: 40px; padding-block: 8px; row-gap: 0; }
|
||||
.settings-footer-auto > :first-child { grid-column: 1 / -1; font-size: 12px; }
|
||||
.settings-footer-auto > :nth-child(2):empty { display: none; }
|
||||
.settings-row:has(> .settings-control > [role="switch"]) {
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) {
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
column-gap: 24px;
|
||||
}
|
||||
.settings-row:has(> .settings-control > [role="switch"]) > :first-child { grid-column: 1; }
|
||||
.settings-row:has(> .settings-control > [role="switch"]) > :nth-child(2) { grid-column: 2; }
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) > :first-child { grid-column: 1; }
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) > :nth-child(2) { grid-column: 2; }
|
||||
.settings-list-row, .settings-list-inset { padding-inline: var(--settings-inset, 16px); }
|
||||
.settings-list-row { min-block-size: 60px; border-radius: var(--radius-control); }
|
||||
.settings-list-row:focus-visible { outline: none; }
|
||||
|
||||
@@ -8,9 +8,11 @@ const AUTOMATIONS_REFRESH_MS = 3000;
|
||||
|
||||
export function useSessionAutomationJobs(open: boolean, token: string, sessionKey: string) {
|
||||
const pageVisible = usePageVisibility();
|
||||
const [jobs, setJobs] = useState<SessionAutomationJob[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loadFailed, setLoadFailed] = useState(false);
|
||||
const [snapshot, setSnapshot] = useState<{
|
||||
sessionKey: string;
|
||||
jobs: SessionAutomationJob[] | null;
|
||||
loadFailed: boolean;
|
||||
}>({ sessionKey, jobs: null, loadFailed: false });
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const tokenRef = useRef(token);
|
||||
tokenRef.current = token;
|
||||
@@ -18,34 +20,28 @@ export function useSessionAutomationJobs(open: boolean, token: string, sessionKe
|
||||
useEffect(() => {
|
||||
if (!open || !pageVisible) return;
|
||||
let cancelled = false;
|
||||
let loadedOnce = false;
|
||||
let refreshing = false;
|
||||
setSnapshot((current) => current.sessionKey === sessionKey
|
||||
? { ...current, loadFailed: false }
|
||||
: { sessionKey, jobs: null, loadFailed: false });
|
||||
|
||||
const refresh = async (showLoading = false) => {
|
||||
const refresh = async () => {
|
||||
if (refreshing) return;
|
||||
refreshing = true;
|
||||
if (showLoading) {
|
||||
setLoading(true);
|
||||
setLoadFailed(false);
|
||||
setJobs([]);
|
||||
}
|
||||
try {
|
||||
const next = await fetchSessionAutomations(tokenRef.current, sessionKey);
|
||||
if (cancelled) return;
|
||||
setJobs(next.jobs);
|
||||
setLoadFailed(false);
|
||||
loadedOnce = true;
|
||||
if (!cancelled) setSnapshot({ sessionKey, jobs: next.jobs, loadFailed: false });
|
||||
} catch {
|
||||
if (!cancelled && !loadedOnce) setLoadFailed(true);
|
||||
if (!cancelled) setSnapshot((current) => current.jobs !== null
|
||||
? current : { sessionKey, jobs: null, loadFailed: true });
|
||||
} finally {
|
||||
refreshing = false;
|
||||
if (!cancelled && showLoading) setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
void refresh(true);
|
||||
const refreshId = window.setInterval(() => void refresh(false), AUTOMATIONS_REFRESH_MS);
|
||||
const refreshOnFocus = () => void refresh(false);
|
||||
void refresh();
|
||||
const refreshId = window.setInterval(() => void refresh(), AUTOMATIONS_REFRESH_MS);
|
||||
const refreshOnFocus = () => void refresh();
|
||||
window.addEventListener("focus", refreshOnFocus);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
@@ -61,5 +57,11 @@ export function useSessionAutomationJobs(open: boolean, token: string, sessionKe
|
||||
return () => window.clearInterval(tickId);
|
||||
}, [open, pageVisible]);
|
||||
|
||||
return { jobs, loading, loadFailed, now };
|
||||
const current = snapshot.sessionKey === sessionKey ? snapshot : null;
|
||||
return {
|
||||
jobs: current?.jobs ?? [],
|
||||
loading: open && current?.jobs == null && !current?.loadFailed,
|
||||
loadFailed: current?.loadFailed ?? false,
|
||||
now,
|
||||
};
|
||||
}
|
||||
@@ -210,6 +210,7 @@ function cachedHistoryState(
|
||||
export function useSessions(): {
|
||||
sessions: ChatSummary[];
|
||||
loading: boolean;
|
||||
initialLoading: boolean;
|
||||
error: string | null;
|
||||
refresh: () => Promise<void>;
|
||||
createChat: (
|
||||
@@ -225,6 +226,7 @@ export function useSessions(): {
|
||||
} {
|
||||
const { client, token } = useClient();
|
||||
const [sessions, setSessions] = useState<ChatSummary[]>(readReloadSessions);
|
||||
const [loadedOnce, setLoadedOnce] = useState(() => sessions.length > 0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const tokenRef = useRef(token);
|
||||
@@ -247,6 +249,7 @@ export function useSessions(): {
|
||||
refreshPendingRef.current = false;
|
||||
try {
|
||||
const rows = await listSessions(tokenRef.current);
|
||||
setLoadedOnce(true);
|
||||
const serverKeys = new Set(rows.map((row) => row.key));
|
||||
setSessions((prev) => {
|
||||
const byKey = new Map(prev.map((row) => [row.key, row]));
|
||||
@@ -379,6 +382,7 @@ export function useSessions(): {
|
||||
return {
|
||||
sessions,
|
||||
loading,
|
||||
initialLoading: loading && !loadedOnce,
|
||||
error,
|
||||
refresh,
|
||||
createChat,
|
||||
|
||||
+11
-1
@@ -28,7 +28,17 @@ initializePairReturn();
|
||||
window.addEventListener("hashchange", initializePairReturn);
|
||||
|
||||
async function renderWebui(container: HTMLElement) {
|
||||
await initializeI18n();
|
||||
// The critical skeleton paints immediately; React must wait for the full stylesheet.
|
||||
const styles = [...document.querySelectorAll<HTMLLinkElement>("link[data-app-stylesheet]")]
|
||||
.map((link) => new Promise<void>((resolve, reject) => {
|
||||
const ready = () => { link.media = "all"; resolve(); };
|
||||
link.addEventListener("load", ready, { once: true });
|
||||
link.addEventListener("error", () => reject(new Error("Failed to load the WebUI stylesheet")), { once: true });
|
||||
link.media = "print";
|
||||
link.rel = "stylesheet";
|
||||
if (link.sheet) ready();
|
||||
}));
|
||||
await Promise.all([initializeI18n(), ...styles]);
|
||||
/* StrictMode disabled: dev double-invokes state updaters; delta accumulation must stay pure — see useNanobotStream. */
|
||||
ReactDOM.createRoot(container).render(<App />);
|
||||
}
|
||||
|
||||
@@ -369,15 +369,16 @@ describe("App layout", () => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("shows only layout shadows while bootstrap is pending", () => {
|
||||
vi.mocked(fetchBootstrap).mockReturnValueOnce(new Promise(() => {}));
|
||||
render(<App />);
|
||||
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
||||
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("link")).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("status")).toHaveClass("startup-status");
|
||||
expect(screen.queryByText("Loading nanobot…")).not.toBeInTheDocument();
|
||||
});
|
||||
it.each(["skills", "apps", "channels", "automations", "settings", "chat"]) (
|
||||
"keeps the %s document skeleton while bootstrap is pending", (surface) => {
|
||||
window.history.replaceState(null, "", `/#/${surface}`);
|
||||
vi.mocked(fetchBootstrap).mockReturnValueOnce(new Promise(() => {}));
|
||||
render(<App />);
|
||||
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
||||
expect(screen.getByRole("main")).toHaveAttribute("data-startup-surface", surface);
|
||||
expect(screen.getByRole("status")).toHaveTextContent("Loading nanobot…");
|
||||
},
|
||||
);
|
||||
|
||||
it.each([false, true])("enables task controls only when bootstrap advertises support: %s", async (supported) => {
|
||||
mockSessions = [{
|
||||
|
||||
@@ -85,6 +85,20 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Automation task list and detail sheet", () => {
|
||||
it("keeps the toolbar during initial loading and retains populated views during refresh", () => {
|
||||
const view = render(<Harness payload={null} loading />);
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toHaveAttribute("aria-busy", "true");
|
||||
const toolbar = screen.getByRole("group", { name: "Task view" }).closest(".automation-panel-toolbar");
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Tasks$/ }));
|
||||
expect(document.querySelectorAll("[data-automation-task-skeleton]")).toHaveLength(3);
|
||||
view.rerender(<Harness loading />);
|
||||
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
|
||||
expect(screen.queryByRole("status", { name: "Loading automations..." })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("group", { name: "Task view" }).closest(".automation-panel-toolbar")).toBe(toolbar);
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Calendar$/ }));
|
||||
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps view selection and filters in one persistent panel toolbar", () => {
|
||||
render(<Harness />);
|
||||
const views = screen.getByRole("group", { name: "Task view" });
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { Window } from "happy-dom";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
||||
import { StartupSkeleton } from "@/components/StartupSkeleton";
|
||||
import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { ContextCompactionNotice } from "@/components/thread/ContextCompactionNotice";
|
||||
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
||||
@@ -338,7 +340,8 @@ const ACCIDENTALLY_SPANISH_SETTINGS_KEYS = [
|
||||
"settings.image.missingCredential",
|
||||
"settings.oauth.signInHelp",
|
||||
];
|
||||
const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8");
|
||||
const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8")
|
||||
.replace("<!--startup-shell-->", renderToStaticMarkup(<StartupSkeleton />));
|
||||
async function runPrebootLocale(storedLocale: string) {
|
||||
const preboot = new Window({
|
||||
url: "http://preboot.test",
|
||||
|
||||
@@ -168,7 +168,8 @@ describe("Linear member access", () => {
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
fireEvent.click(header());
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
expect(screen.getByText("Finding members…")).toBeVisible();
|
||||
expect(screen.getByRole("status", { name: "Finding members…" })).toHaveAttribute("aria-busy", "true");
|
||||
expect(document.querySelectorAll("[data-member-skeleton-row]")).toHaveLength(3);
|
||||
expect(screen.getByRole("textbox", { name: "Search members" })).toBeEnabled();
|
||||
expect(header()).toBeEnabled();
|
||||
expect(document.querySelector(".animate-spin")).toBeNull();
|
||||
|
||||
@@ -86,6 +86,31 @@ describe("SessionInfoPopover", () => {
|
||||
expect(screen.getByRole("button", { name: "Session details" })).toHaveFocus();
|
||||
});
|
||||
|
||||
it("uses a skeleton for the initial request and keeps jobs while reopening and refreshing", async () => {
|
||||
let finish!: (response: Response) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
const user = userEvent.setup();
|
||||
const view = render(<SessionInfoPopover client={client} sessionKey="websocket:chat-1" token="tok" title="Release work" />);
|
||||
await user.click(screen.getByRole("button", { name: "Session details" }));
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => finish(automationsResponse([automationJob()])));
|
||||
expect(await screen.findByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
await user.keyboard("{Escape}");
|
||||
let fail!: (error: Error) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((_, reject) => { fail = reject; }));
|
||||
await user.click(screen.getByRole("button", { name: "Session details" }));
|
||||
expect(screen.getByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
expect(screen.queryByRole("status", { name: "Loading automations..." })).not.toBeInTheDocument();
|
||||
await act(async () => fail(new Error("Refresh failed")));
|
||||
expect(screen.getByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
view.rerender(<SessionInfoPopover client={client} sessionKey="websocket:chat-2" token="tok" title="Other project" />);
|
||||
expect(screen.queryByRole("button", { name: /Morning check/ })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toBeVisible();
|
||||
await act(async () => finish(automationsResponse([])));
|
||||
expect(await screen.findByText("No automations in this session yet.")).toBeVisible();
|
||||
});
|
||||
|
||||
it("manages a session task through the shared detail dialog", async () => {
|
||||
const boundJob = { ...automationJob(), origin: {
|
||||
session_key: "websocket:chat-1", channel: "websocket", chat_id: "chat-1",
|
||||
|
||||
@@ -164,6 +164,32 @@ describe("Settings system domains", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
["skills", "Loading skills…"],
|
||||
["apps", "Loading apps…"],
|
||||
["channels", "Loading channels…"],
|
||||
["automations", "Loading automations..."],
|
||||
] as const)("keeps the %s loading surface mounted when the settings snapshot arrives", async (initialSection, label) => {
|
||||
let resolveSettings!: (value: Response) => void;
|
||||
const pendingSettings = new Promise<Response>((resolve) => { resolveSettings = resolve; });
|
||||
vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => String(input) === "/api/settings"
|
||||
? pendingSettings : new Promise<Response>(() => {})));
|
||||
renderSettingsView({ initialSection, initialSettings: null, skillsLoading: true, showSidebar: false });
|
||||
const skeleton = screen.getByRole("status", { name: label });
|
||||
expect(skeleton).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => { resolveSettings(jsonResponse(settingsPayload())); });
|
||||
expect(screen.getByRole("status", { name: label })).toBe(skeleton);
|
||||
});
|
||||
|
||||
it("shows available skills while the unrelated settings snapshot is still pending", () => {
|
||||
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>(() => {})));
|
||||
renderSettingsView({ initialSection: "skills", initialSettings: null, showSidebar: false, skills: [{
|
||||
name: "project-review", description: "Review a project.", source: "builtin", available: true, enabled: true,
|
||||
}] });
|
||||
expect(screen.getByRole("button", { name: "Open details for project-review" })).toBeVisible();
|
||||
expect(screen.getByRole("textbox", { name: "Search installed skills" })).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps the regular settings page at its existing width", () => {
|
||||
renderSettingsView({ initialSection: "models", initialSettings: settingsPayload() });
|
||||
|
||||
@@ -258,6 +284,32 @@ describe("Settings system domains", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("loads only the skill detail body and preserves it while checking dependencies again", async () => {
|
||||
const skill = { name: "pr-review", description: "Review pull requests", source: "builtin", available: false, enabled: true };
|
||||
let finish!: (response: Response) => void;
|
||||
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>((resolve) => { finish = resolve; })));
|
||||
render(<ClientProvider client={{} as never} token="tok"><SkillsCatalogSettings skills={[skill]} /></ClientProvider>);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Open details for pr-review" }));
|
||||
const detail = screen.getByRole("dialog");
|
||||
expect(within(detail).getByText("Review pull requests")).toBeVisible();
|
||||
expect(within(detail).getByRole("status", { name: "Loading skill details..." })).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => finish(jsonResponse({ ...skill, raw_markdown: "Review repository changes.", requirements: {
|
||||
bins: ["gh"], env: [], missing_bins: ["gh"], missing_env: [],
|
||||
} })));
|
||||
const toggle = within(detail).getByRole("switch");
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
let fail!: (error: Error) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((_, reject) => { fail = reject; }));
|
||||
fireEvent.click(within(detail).getByRole("button", { name: "Check again" }));
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
expect(toggle).toBeDisabled();
|
||||
expect(within(detail).queryByRole("status", { name: "Loading skill details..." })).not.toBeInTheDocument();
|
||||
await act(async () => fail(new Error("Read failed")));
|
||||
expect(within(detail).getByRole("alert")).toHaveTextContent("Could not load skill details.");
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
expect(toggle).toBeEnabled();
|
||||
});
|
||||
|
||||
it("keeps skill group labels natural without changing grouping or filtering", () => {
|
||||
render(<ClientProvider client={{} as never} token="tok">
|
||||
<SkillsCatalogSettings skills={[
|
||||
|
||||
@@ -140,7 +140,9 @@ export function renderSettingsView(
|
||||
| "image"
|
||||
| "browser"
|
||||
| "runtime";
|
||||
initialSettings?: SettingsPayload;
|
||||
initialSettings?: SettingsPayload | null;
|
||||
skills?: React.ComponentProps<typeof SettingsView>["skills"];
|
||||
skillsLoading?: boolean;
|
||||
showSidebar?: boolean;
|
||||
mainNavigationExpanded?: boolean;
|
||||
onBackToChat?: () => void;
|
||||
@@ -163,6 +165,8 @@ export function renderSettingsView(
|
||||
theme="light"
|
||||
initialSection={options.initialSection ?? "apps"}
|
||||
initialSettings={options.initialSettings}
|
||||
skills={options.skills}
|
||||
skillsLoading={options.skillsLoading}
|
||||
showSidebar={options.showSidebar}
|
||||
mainNavigationExpanded={options.mainNavigationExpanded}
|
||||
onToggleTheme={() => {}}
|
||||
|
||||
@@ -74,6 +74,20 @@ function wrap(
|
||||
}
|
||||
|
||||
describe("useSessions", () => {
|
||||
it("distinguishes initial loading from revalidating a successfully loaded empty list", async () => {
|
||||
let finish!: (rows: Awaited<ReturnType<typeof api.listSessions>>) => void;
|
||||
vi.mocked(api.listSessions).mockImplementation(() => new Promise((resolve) => { finish = resolve; }));
|
||||
const { result } = renderHook(() => useSessions(), { wrapper: wrap(fakeClient()) });
|
||||
expect(result.current.initialLoading).toBe(true);
|
||||
await act(async () => finish([]));
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
let refresh!: Promise<void>;
|
||||
act(() => { refresh = result.current.refresh(); });
|
||||
expect(result.current.loading).toBe(true);
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
await act(async () => { finish([]); await refresh; });
|
||||
});
|
||||
|
||||
it("shows tab-cached sessions while revalidating and removes server-deleted rows", async () => {
|
||||
activateReloadCache("ws://localhost:8765/");
|
||||
writeReloadCache("sessions", [{
|
||||
@@ -86,6 +100,7 @@ describe("useSessions", () => {
|
||||
try {
|
||||
expect(result.current.sessions[0]?.key).toBe("websocket:cached");
|
||||
expect(result.current.loading).toBe(true);
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
await act(async () => finish([]));
|
||||
expect(result.current.sessions).toEqual([]);
|
||||
expect(result.current.loading).toBe(false);
|
||||
|
||||
+26
-1
@@ -3,8 +3,33 @@ import react from "@vitejs/plugin-react";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { gzipSync } from "node:zlib";
|
||||
import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { readStartupLayout, StartupSkeleton } from "./src/components/StartupSkeleton";
|
||||
import { componentGallery } from "./src/dev/gallery/inventory-plugin";
|
||||
|
||||
function startupSkeleton(): Plugin {
|
||||
return {
|
||||
name: "nanobot-startup-skeleton",
|
||||
transformIndexHtml: {
|
||||
order: "post",
|
||||
handler(html) {
|
||||
if (!html.includes("<!--startup-shell-->")) return html;
|
||||
const css = readFileSync(path.resolve(__dirname, "src/components/startup-skeleton.css"), "utf8");
|
||||
const initialize = `var shell = document.querySelector('.startup-shell'); var layout = (${readStartupLayout.toString()})();
|
||||
shell.dataset.startupSurface = layout.surface; shell.dataset.startupSection = layout.section;
|
||||
shell.dataset.sidebarExpanded = String(layout.sidebarExpanded); shell.dataset.existingChat = String(layout.existingChat);
|
||||
shell.dataset.calendarWeeks = String(layout.calendarWeeks);
|
||||
shell.style.setProperty('--startup-sidebar-width', (layout.sidebarExpanded ? layout.sidebarWidth : 56) + 'px');`;
|
||||
return html.replace("<!--startup-style-->", `<style>${css}</style>`)
|
||||
.replace("<!--startup-shell-->", renderToStaticMarkup(createElement(StartupSkeleton)))
|
||||
.replace("<!--startup-script-->", `<script>${initialize}</script>`)
|
||||
.replace(/<link rel="stylesheet"/g, '<link rel="preload" as="style" data-app-stylesheet');
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const GZIP_MIN_BYTES = 4 * 1024;
|
||||
const GZIP_ASSET_PATTERN = /\.(?:css|html|js|json|mjs|svg)$/i;
|
||||
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "syntax-highlight-", "katex-"];
|
||||
@@ -120,7 +145,7 @@ export default defineConfig(({ mode }) => {
|
||||
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"),
|
||||
|
||||
Reference in new issue
Block a user