Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(browser): read Xft.dpi only in an X11 session
Bugfixer 2d9525b299208
diff --git a/server/browser/display.test.ts b/server/browser/display.test.tsindex c3b023c8db..2aebb31f17 100644--- a/server/browser/display.test.ts+++ b/server/browser/display.test.ts@@ -40,6 +40,8 @@ describe("the display a headless bot browser reports", () => {expect(await linux("Xft.dpi:\t96\n")).toEqual({ width: 3840, height: 2160, deviceScaleFactor: 1 });expect(await linux("*customization:\t-color\n")).toEqual({ width: 3840, height: 2160, deviceScaleFactor: 1 });expect(await linux(new Error("no xrdb"))).toEqual({ width: 3840, height: 2160, deviceScaleFactor: 1 });+ expect(await linux("Xft.dpi:\t192\n", { DISPLAY: ":0", WAYLAND_DISPLAY: "wayland-0" })).toEqual({ width: 3840, height: 2160, deviceScaleFactor: 1 });+ expect(await linux("Xft.dpi:\t192\n", { DISPLAY: ":0", XDG_SESSION_TYPE: "wayland" })).toEqual({ width: 3840, height: 2160, deviceScaleFactor: 1 });});it("is a declared 1920x1080 at 1x on a server or in a container, and when the desktop cannot be read", async () => {diff --git a/server/browser/display.ts b/server/browser/display.tsindex ae6cc23394..4a4d080fd7 100644--- a/server/browser/display.ts+++ b/server/browser/display.ts@@ -48,7 +48,9 @@ export async function displayScreen(host: HostKind, { platform = process.platforconst pixels = parseDisplay(lines.find((line) => / primary /u.test(line)) ?? lines[0] ?? "");if (!pixels) return SERVER_SCREEN;const gdkScale = Number(env.GDK_SCALE);- const scale = Number.isInteger(gdkScale) && gdkScale > 1 && gdkScale <= 4 ? gdkScale : await xftScale(runCommand);+ // Under Wayland, XWayland's RandR size can already be logical, so Xft.dpi is only read in an X11 session.+ const x11 = !env.WAYLAND_DISPLAY && env.XDG_SESSION_TYPE !== "wayland";+ const scale = Number.isInteger(gdkScale) && gdkScale > 1 && gdkScale <= 4 ? gdkScale : x11 ? await xftScale(runCommand) : 1;return { width: Math.round(pixels.width / scale), height: Math.round(pixels.height / scale), deviceScaleFactor: scale };}} catch {}