fix(webui): restore startup flow while keeping recovery batching (#6712)

* fix(webui): restore startup flow while keeping recovery batching

Keep the two restart recovery scans from #6708. Withdraw the browser preload and launcher changes until they can be measured independently against the Windows first-send regression.

* fix(webui): skip graph layout measurement in reduced motion

A zero-duration shared layout still measured the panel while the 500-node graph was mounting. Disable the shared-layout link in reduced motion and start the browser budget after the initial graph paints. Keep the existing 150ms limit and all 500 node checks.
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-18 23:40:49 +08:00
1 parent cab49a1c66
commit 995f9e36c1
21 files changed
+260 -400

No files matched your search

@@ -1,55 +0,0 @@
import { act, screen } from "@testing-library/react";
import ReactDOM from "react-dom/client";
import { expect, it, vi } from "vitest";
const events = vi.hoisted(() => [] as string[]);
vi.mock("@/mount", async (original) => {
events.push("mount module");
return original<typeof import("@/mount")>();
});
vi.mock("@/components/thread/ThreadShell", () => {
events.push("thread module");
return { ThreadShell: () => null };
});
it("starts the fragment-authenticated request and chat import before mount, then consumes even a fast 401 once", async () => {
const root = document.createElement("div");
root.id = "root";
root.innerHTML = '<main data-startup-surface="chat" aria-busy="true"></main>';
document.body.append(root);
const css = document.createElement("link");
css.dataset.appStylesheet = "";
document.head.append(css);
window.history.replaceState(null, "", "/#/?bootstrapSecret=from-fragment&keep=1");
const createRoot = vi.spyOn(ReactDOM, "createRoot");
const request = vi.fn(async () => {
events.push("bootstrap");
return new Response(null, { status: 401 });
});
vi.stubGlobal("fetch", request);
try {
await import("@/main");
await vi.dynamicImportSettled();
expect(events[0]).toBe("bootstrap");
expect(events).toContain("thread module");
expect(events).toContain("mount module");
expect(request).toHaveBeenCalledWith("/webui/bootstrap", expect.objectContaining({
credentials: "same-origin", cache: "no-store", headers: { "X-Nanobot-Auth": "from-fragment" },
}));
expect(window.location.hash).toBe("#/?keep=1");
expect(createRoot).not.toHaveBeenCalled();
expect(root.querySelector("input, textarea")).toBeNull();
await act(async () => { css.dispatchEvent(new Event("load")); });
expect(await screen.findByLabelText("WebUI password")).toBeVisible();
expect(request).toHaveBeenCalledTimes(1);
expect(localStorage.getItem("nanobot-webui.bootstrap-secret")).toBeNull();
} finally {
await act(async () => { createRoot.mock.results[0]?.value?.unmount(); });
vi.restoreAllMocks();
vi.unstubAllGlobals();
window.history.replaceState(null, "", "/");
css.remove();
root.remove();
}
});
+1 -3
View File
@@ -101,9 +101,7 @@ describe("webuiManualChunk", () => {
expect(webuiManualChunk("/repo/node_modules/react-dom/client.js")).toBe("react-vendor");
expect(webuiManualChunk("/repo/node_modules/scheduler/index.js")).toBe("react-vendor");
expect(webuiManualChunk("/repo/node_modules/clsx/dist/clsx.mjs")).toBe("react-vendor");
});
it("does not make the document's dynamic-import helper pull in React DOM", () => {
expect(webuiManualChunk("\0vite/preload-helper.js")).toBe("preload-helper");
expect(webuiManualChunk("\0vite/preload-helper.js")).toBe("react-vendor");
});
it("keeps markdown-only hast utilities in the markdown chunk", () => {