A desktop coding agent with free access to frontier models.
TypeScript
Grant native Windows helper foreground access on approval
Task Buildered08bd58fb06
diff --git a/apps/desktop/electron/computer-use-native.mjs b/apps/desktop/electron/computer-use-native.mjsindex de518abf..f6dbce0e 100644--- a/apps/desktop/electron/computer-use-native.mjs+++ b/apps/desktop/electron/computer-use-native.mjs@@ -1,4 +1,5 @@import { spawn } from "node:child_process";+import { createRequire } from "node:module";import { fileURLToPath } from "node:url";/** @param {unknown} value @returns {value is Record<string, unknown>} */function record(value) { return typeof value === "object" && value !== null && !Array.isArray(value); }@@ -31,6 +32,11 @@ export function createNativeDesktop() {worker.on("exit", () => fail(new Error("Desktop access stopped. Restart OmniRush.ai.")));return {ready,+ grantForeground() {+ if (process.platform !== "win32" || !worker.pid) return;+ const koffi = createRequire(import.meta.url)("koffi");+ koffi.load("user32.dll").func("int __stdcall AllowSetForegroundWindow(uint32_t processId)")(worker.pid);+ },onInput(listener) { listeners.add(listener); return () => listeners.delete(listener); },call(method, params = {}) {if (closed) return Promise.reject(new Error("Desktop access has stopped."));diff --git a/apps/desktop/electron/computer-use-portable-host.mjs b/apps/desktop/electron/computer-use-portable-host.mjsindex eb7397a8..2bd40edd 100644--- a/apps/desktop/electron/computer-use-portable-host.mjs+++ b/apps/desktop/electron/computer-use-portable-host.mjs@@ -233,7 +233,10 @@ export async function createPortableComputerUseHost({ profile, capture, previewif (!selected) throw new Error("Choose a window.");const current = await native.call("window", { id: selected.id });if (current.identity !== selected.identity) { await stop(entry); throw new Error("The app restarted. Start a new session."); }- if (value.mode === "control") await native.call("focus", { window: current });+ if (value.mode === "control") {+ native.grantForeground?.();+ await native.call("focus", { window: current });+ }if (entry.session !== value) throw new Error("The request ended.");value.window = current; value.phase = "working"; value.status = ""; value.lastOperation = Date.now(); value.observation = null;if (input.action === "approve") value.expiresAt = Date.now() + 900_000;