;
useUi.getState().hydrate(s);
applyTheme(s.theme);
applyChatLayout(s);
} catch {}
// Fetch the project/conversation/provider lists and subscribe to the sidebar channel
await useData.getState().bind(ws);
});
setInterval(() => ws.ping(), 10000);
const isDebug = params.get("debug") === "1";
const root = createRoot(document.getElementById("root")!);
let renders = 0;
function renderApp(): void {
renders++;
root.render(isDebug ? : );
}
renderApp();
// ?audit=1 (§11.3 screenshot self-check metrics): count visible borders on the first screen, font-size set, accent-colored elements, horizontal scroll,
// written to (after 1.5s so the first screen settles).
if (params.get("audit") === "1") {
setTimeout(() => {
try {
const vw = window.innerWidth;
const docW = document.documentElement.scrollWidth;
const fontSizes = new Set();
const accentEls: string[] = [];
let borders = 0;
const accent = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim();
const inFirstScreen = (r: DOMRect) => r.top < window.innerHeight && r.bottom > 0 && r.width > 0;
document.querySelectorAll("*").forEach((el) => {
const e = el as HTMLElement;
const cs = getComputedStyle(e);
const r = e.getBoundingClientRect();
if (!inFirstScreen(r) || cs.display === "none" || cs.visibility === "hidden") return;
if (r.width < 3 || r.height < 3) return;
fontSizes.add(cs.fontSize);
if (cs.borderTopWidth !== "0px" && cs.borderTopStyle !== "none") borders++;
if (cs.borderBottomWidth !== "0px" && cs.borderBottomStyle !== "none") borders++;
// Accent-colored elements (background or text color equals the resolved --accent)
const bg = cs.backgroundColor, fg = cs.color;
if (accent && (bg === accent || fg === accent)) {
const cls = (e.getAttribute("class") ?? "").split(" ")[0];
if (!accentEls.includes(cls)) accentEls.push(cls);
}
});
const out = {
vw, docW,
noHScroll: docW <= vw + 1,
fontSizes: [...fontSizes].sort(),
bordersFirstScreen: borders,
accentEls,
};
const pre = document.createElement("pre");
pre.id = "audit";
pre.style.display = "none";
pre.textContent = JSON.stringify(out);
document.body.appendChild(pre);
} catch (e) {
const pre = document.createElement("pre");
pre.id = "audit";
pre.textContent = JSON.stringify({ error: String(e) });
document.body.appendChild(pre);
}
}, 1500);
}