Skip to content

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

Tests: page tests keep the fake event stream; a direct browser uses WebSocket only when it has one

milind-soni72a7b7e4146a
diff --git a/server/testing/setup.ts b/server/testing/setup.ts
index e9ebc17da6..4ca53e1ab5 100644
--- a/server/testing/setup.ts
+++ b/server/testing/setup.ts
@@ -34,6 +34,8 @@ process.env.OMB_COMPANION_DIR = join(home, ".openmausbot-companion");
// Product code follows navigator.language; pin it so English assertions do not depend on the host locale.
Object.defineProperty(globalThis.navigator, "language", { value: "en", configurable: true });
+// Page tests drive the live feed through a fake EventSource; without this a direct page would open a real socket first.
+if (typeof window !== "undefined") Reflect.deleteProperty(globalThis, "WebSocket");
// Windows will not remove a directory holding an open SQLite database: close it before the reset.
const { closeMessageDb } = await import("../message-db.ts");
diff --git a/src/lib/websocket-events.ts b/src/lib/websocket-events.ts
index be2781dc2d..7204813477 100644
--- a/src/lib/websocket-events.ts
+++ b/src/lib/websocket-events.ts
@@ -1,7 +1,7 @@
import { relayLink, type LiveEventSourceLike } from "./relay-server";
export function isDirectWebBrowser(): boolean {
- return typeof window !== "undefined" && !window.ogb?.platform && !relayLink();
+ return typeof window !== "undefined" && typeof WebSocket === "function" && !window.ogb?.platform && !relayLink();
}
export function websocketEvents(url: string): LiveEventSourceLike {