Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

The window is named MausBot before the brand file answers (#4186)

Milind Soni239a31368427
diff --git a/src/lib/title-at-boot.test.ts b/src/lib/title-at-boot.test.ts
new file mode 100644
index 0000000000..e81458850b
--- /dev/null
+++ b/src/lib/title-at-boot.test.ts
@@ -0,0 +1,17 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+
+import { PRODUCT_NAME } from "./brand";
+
+// The packaged Linux smoke reads document.title once the page has loaded, before /api/brand has answered, and a person
+// sees the same name in the window title at that moment: the product's name is set before anything is fetched.
+describe("the window's name at boot", () => {
+ it("is the product's name before the brand file is asked for", () => {
+ const main = readFileSync(new URL("../main.tsx", import.meta.url), "utf8");
+ const title = main.indexOf("document.title = productName();");
+ const fetch = main.indexOf("bootstrapBrand()");
+ expect(title).toBeGreaterThan(-1);
+ expect(fetch).toBeGreaterThan(title);
+ expect(PRODUCT_NAME).toBe("MausBot");
+ });
+});
diff --git a/src/main.tsx b/src/main.tsx
index 578acbac1c..2bc22a4f91 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -3,7 +3,7 @@ import { createRoot } from "react-dom/client";
import {
BROWSER_SIGN_IN_FAILED, previewBrowserSignIn, readSessionState, SERVICE_TRUST_REASON, takeBrowserSignInFromLocation, takePairingCodeFromLocation, takeInvitedEmailFromLocation,
} from "./lib/session";
-import { bootstrapBrand } from "./lib/brand";
+import { bootstrapBrand, productName } from "./lib/brand";
import { loadPageLanguage } from "./lib/language-preference";
import { applySkinChoice, readSkinChoice } from "./lib/skins";
import { applyChatWidth, readChatWidth } from "./lib/chat-width";
@@ -54,6 +54,8 @@ async function chooseRoot(): Promise<React.ReactNode> {
return <App />;
}
+// The window is named before the brand file is asked for: the answer only ever renames it.
+document.title = productName();
void Promise.all([bootstrapBrand(), chooseRoot(), loadPageLanguage()]).then(([, root]) => {
createRoot(document.getElementById("root")!).render(<StrictMode><PageBoundary>{root}</PageBoundary></StrictMode>);
});