* 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.
60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
import ReactDOM from "react-dom/client";
|
|
|
|
import App from "./App";
|
|
import "./globals.css";
|
|
import { initializeI18n } from "./i18n";
|
|
import { initializePairReturn } from "./lib/remote-pair-return";
|
|
|
|
// `crypto.randomUUID` is only defined in secure contexts (HTTPS or localhost).
|
|
// LAN access over plain HTTP leaves it undefined, which crashes components that
|
|
// generate client-side message IDs. Shim a v4-ish fallback so call sites stay
|
|
// uniform across secure and non-secure contexts.
|
|
if (typeof globalThis.crypto !== "undefined" && !("randomUUID" in globalThis.crypto)) {
|
|
Object.defineProperty(globalThis.crypto, "randomUUID", {
|
|
value: () =>
|
|
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
const r = (Math.random() * 16) | 0;
|
|
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
return v.toString(16);
|
|
}),
|
|
configurable: true,
|
|
});
|
|
}
|
|
|
|
const root = document.getElementById("root");
|
|
if (!root) throw new Error("root element missing");
|
|
|
|
initializePairReturn();
|
|
window.addEventListener("hashchange", initializePairReturn);
|
|
|
|
async function renderWebui(container: HTMLElement) {
|
|
// 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 />);
|
|
}
|
|
|
|
void renderWebui(root);
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
window.addEventListener("load", () => {
|
|
navigator.serviceWorker
|
|
.register("/sw.js", {
|
|
updateViaCache: "none",
|
|
})
|
|
.catch(() => {
|
|
// Service workers are progressive enhancement; registration failures
|
|
// (unsupported proxies, blocked storage) must not break the app.
|
|
});
|
|
});
|
|
}
|