Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(desktop): the app menu's Settings opens on a remote server's page (#4029)
Aditya Umale604f5575f6e2
diff --git a/electron/home-window.node-test.mjs b/electron/home-window.node-test.mjsindex 7e5ce905e5..9741013191 100644--- a/electron/home-window.node-test.mjs+++ b/electron/home-window.node-test.mjs@@ -358,20 +358,21 @@ test("the window's IPC: the screen reads and retries, My Cloud's page renews itsconst PRELOAD = readFileSync(new URL("./preload.cjs", import.meta.url), "utf8");function preload(origin, { home = false, activation = false } = {}) {- let bridge; const invoked = [], synced = [];+ let bridge; const invoked = [], synced = [], listeners = new Map();vm.runInNewContext(PRELOAD, {process: { platform: "darwin", argv: [`--omb-local-origin=${LOCAL}`, "--omb-company-desktop=1"] },location: { origin }, navigator: { userActivation: { isActive: activation } }, TextEncoder, localStorage: { getItem: () => null },queueMicrotask,require: () => ({ webUtils: {}, contextBridge: { exposeInMainWorld: (_name, value) => { bridge = value; } },- ipcRenderer: { on() {}, removeListener() {}, send() {}, sendSync: (channel) => { synced.push(channel); return channel === "home:page" ? home : null; },+ ipcRenderer: { on: (channel, listener) => listeners.set(channel, listener), removeListener() {}, send() {}, sendSync: (channel) => { synced.push(channel); return channel === "home:page" ? home : null; },invoke: (...args) => { invoked.push(args); return Promise.resolve(); } } }),});- return { bridge, invoked, synced };+ const tell = (channel, ...args) => listeners.get(channel)?.({}, ...args);+ return { bridge, invoked, synced, tell };}-test("My Cloud's own page, once it is home, gets this app's chat links, Settings key, diagnostics and its session renewal; any other server's page doesn't", async () => {- const keys = ["home", "onChatLink", "onPackageInstall", "onOpenAppSettings", "exportDiagnostics", "openLogsFolder"];+test("My Cloud's own page, once it is home, gets this app's chat links, diagnostics and its session renewal; any other server's page doesn't", async () => {+ const keys = ["home", "onChatLink", "onPackageInstall", "exportDiagnostics", "openLogsFolder"];const home = preload(CLOUD, { home: true });for (const key of keys) assert.ok(home.bridge[key], key);assert.ok(home.synced.includes("home:page"));@@ -386,6 +387,12 @@ test("My Cloud's own page, once it is home, gets this app's chat links, Settingsassert.deepEqual([...home.invoked, ...clicked.invoked].map(([channel]) => channel), ["home:repair", "home:sign-in", "home:sign-in"]);const other = preload("https://bots.example.test", { home: false });for (const key of keys) assert.equal(other.bridge[key], undefined, key);+ for (const page of [home, other]) {+ const opened = [];+ page.bridge.onOpenAppSettings(section => opened.push(section ?? "settings"));+ page.tell("app:open-settings");+ assert.deepEqual(opened, ["settings"], "the app menu's Settings reaches every server's page");+ }const local = preload(LOCAL);for (const key of keys) assert.ok(local.bridge[key], key);assert.equal(local.synced.includes("home:page"), false, "this computer's page never needs to ask");diff --git a/electron/preload.cjs b/electron/preload.cjsindex 1256055d7b..978df21059 100644--- a/electron/preload.cjs+++ b/electron/preload.cjs@@ -64,9 +64,9 @@ function railKeepsItsSize() {if (typeof window !== "undefined") {for (const type of ["resize", "DOMContentLoaded"]) window.addEventListener(type, () => { leaveRailRoom(); railKeepsItsSize(); });}-const REMOTE_SAFE = new Set(["platform", "app", "getCapabilities", "onCapabilitiesChanged", "applySkin", "setUnreadCount", "permStatus", "workspaces", "rail", "cloudAdd", "cloudPlan", "cloudSendPage", "desktopNotices", "desktopAnalytics", "desktopLanguage", "updatesConsent", "windowControls"]);+const REMOTE_SAFE = new Set(["platform", "app", "getCapabilities", "onCapabilitiesChanged", "applySkin", "setUnreadCount", "permStatus", "workspaces", "rail", "cloudAdd", "cloudPlan", "cloudSendPage", "desktopNotices", "desktopAnalytics", "desktopLanguage", "updatesConsent", "windowControls", "onOpenAppSettings"]);/** My Cloud's own page once it is the person's home (main checks the sender again): it is this app's page then. */-const HOME_PAGE = ["home", "onChatLink", "onPackageInstall", "onOpenAppSettings", "exportDiagnostics", "openLogsFolder", "openAtLogin", "callActive"];+const HOME_PAGE = ["home", "onChatLink", "onPackageInstall", "exportDiagnostics", "openLogsFolder", "openAtLogin", "callActive"];function updaterOffered() {try { return ipcRenderer.sendSync("update:offered") === true; } catch { return false; }}diff --git a/electron/preload.node-test.mjs b/electron/preload.node-test.mjsindex 2dac7a6b13..e9e3fd0e97 100644--- a/electron/preload.node-test.mjs+++ b/electron/preload.node-test.mjs@@ -47,7 +47,6 @@ const subscriberCount = (channel) => listeners.get(channel)?.size ?? 0;test("exposes the full local-shell bridge on window.ogb", () => {assert.equal(exposed.name, "ogb");assert.equal(typeof exposed.api, "object");- // The settings channel is local-shell only, and this page is local (no --omb-local-origin in argv here).assert.equal(typeof exposed.api.onOpenAppSettings, "function");});diff --git a/src/types/ogb.d.ts b/src/types/ogb.d.tsindex 16f351ad38..2319dfa469 100644--- a/src/types/ogb.d.ts+++ b/src/types/ogb.d.ts@@ -352,8 +352,8 @@ const __APP_VERSION__: string;* opened from outside the app. */onChatLink?(cb: (link: string) => void): () => void;/** The desktop shell's app-menu Preferences… item was activated; open- * app Settings. Local-shell only: remote server pages never receive- * the channel, and the bridge is absent in the browser. "cloud" is the+ * app Settings. Every server's page in the window receives it, and the+ * bridge is absent in the browser. "cloud" is the* openmausbot://cloud link (Settings → OMB Cloud, opened by the link). */onOpenAppSettings?(cb: (section?: "organization" | "cloud" | "cloud-settings" | "cloud-add" | "cloud-add-howto") => void): () => void;/** Updates the native Dock/taskbar unread indicator. */