A desktop coding agent with free access to frontier models.
TypeScript
fix: keep native preview clear and Stop reachable from the app
Task Builder455ec4a2da9d
diff --git a/.github/workflows/evidence-review.yml b/.github/workflows/evidence-review.ymlindex 58ddb5fc..1d84d16a 100644--- a/.github/workflows/evidence-review.yml+++ b/.github/workflows/evidence-review.yml@@ -43,7 +43,7 @@ jobs:- uses: pnpm/action-setup@v4- name: Install review and testkit dependenciesrun: |- pnpm --filter @omnirush/review-app... --filter @omnirush/world... --filter @omnirush/types... install --frozen-lockfile --ignore-scripts+ pnpm --filter @omnirush/review-app... --filter @omnirush/world... --filter @omnirush/types... --filter omnirush-server... install --frozen-lockfile --ignore-scriptspnpm --dir evals install --frozen-lockfile --ignore-scripts- name: Build and verify the review appenv:diff --git a/apps/app/src/react-app/domains/session/surface/computer-use-controls.tsx b/apps/app/src/react-app/domains/session/surface/computer-use-controls.tsxindex 24667941..5fcf3c08 100644--- a/apps/app/src/react-app/domains/session/surface/computer-use-controls.tsx+++ b/apps/app/src/react-app/domains/session/surface/computer-use-controls.tsx@@ -31,7 +31,10 @@ export function ComputerUseControls() {const selectedWindow = windows[session.id] ?? session.windows?.[0]?.id;const send = (command: string) => action.mutate({ connectionId: session.connectionId, id: session.id, action: command, windowId: selectedWindow });if (!approval && !blocked) {- return session.previewVisible ? null : <Button key={session.connectionId} variant="outline" onClick={() => send("show")}>Show {session.appName} preview</Button>;+ return session.previewVisible ? null : <div key={session.connectionId} className="flex justify-end gap-2">+ <Button variant="outline" onClick={() => send("show")}>Show {session.appName} preview</Button>+ <Button variant="destructive" disabled={action.isPending} onClick={() => send("stop")}>Stop</Button>+ </div>;}return <section key={session.connectionId} className="rounded-2xl border border-border bg-background p-4 shadow-lg"><p className="text-sm font-semibold">{approval ? `Use ${session.appName}?` : `Computer Use · ${session.appName}`}</p>diff --git a/apps/app/src/react-app/domains/settings/computer-use-config.tsx b/apps/app/src/react-app/domains/settings/computer-use-config.tsxindex 44c50cee..e4c4009e 100644--- a/apps/app/src/react-app/domains/settings/computer-use-config.tsx+++ b/apps/app/src/react-app/domains/settings/computer-use-config.tsx@@ -157,7 +157,7 @@ export function ComputerUseConfig({ connected, connecting, onConnect, onRefresh,</div> : null}<p className="text-xs leading-relaxed text-muted-foreground">{!mac ? "Keep the target app visible on an unlocked desktop. Computer Use moves the mouse and types in the foreground; choose Continue after taking over. Choose a model that accepts images. For background Blender work, ask for a Blender Python script or use an app connector. " : null}- Sessions end after 15 minutes and pause when idle. Window content is processed by your selected model provider. Enter passwords yourself. For websites, use the built-in browser.+ Hide the preview if it covers app controls; Stop stays available in the OmniRush.ai window. Sessions end after 15 minutes and pause when idle. Window content is processed by your selected model provider. Enter passwords yourself. For websites, use the built-in browser.</p></CardContent><CardFooter className="flex flex-wrap items-center justify-between gap-3 border-t border-border">diff --git a/apps/desktop/electron/computer-use-portable-host.mjs b/apps/desktop/electron/computer-use-portable-host.mjsindex 32e6b3ab..eb7397a8 100644--- a/apps/desktop/electron/computer-use-portable-host.mjs+++ b/apps/desktop/electron/computer-use-portable-host.mjs@@ -46,7 +46,7 @@ export async function createPortableComputerUseHost({ profile, capture, previewconst state = () => [...connections.values()].flatMap((entry) => entry.session ? [{connectionId: entry.id, id: entry.session.id, phase: entry.session.phase, appName: entry.session.window.appName,task: entry.session.purpose, mode: entry.session.mode, windows: entry.session.windows.map((w) => ({ id: w.id, title: w.title })),- windowTitle: entry.session.window.title, status: entry.session.status, recoverable: false,+ windowTitle: entry.session.window.title, windowBounds: entry.session.window.bounds, status: entry.session.status, recoverable: false,canContinue: entry.session.phase === "paused", previewVisible: entry.session.previewVisible,remainingSeconds: Math.max(0, Math.ceil((entry.session.expiresAt - Date.now()) / 1000)),}] : []);diff --git a/apps/desktop/electron/computer-use-preview.mjs b/apps/desktop/electron/computer-use-preview.mjsindex 79bccef3..293fdfd2 100644--- a/apps/desktop/electron/computer-use-preview.mjs+++ b/apps/desktop/electron/computer-use-preview.mjs@@ -1,4 +1,4 @@-import { BrowserWindow, ipcMain, desktopCapturer } from "electron";+import { BrowserWindow, ipcMain, desktopCapturer, screen } from "electron";import { fileURLToPath } from "node:url";export async function captureComputerWindow(window) {const limit = 1600, ratio = Math.min(1, limit / Math.max(window.bounds.width, window.bounds.height));@@ -10,7 +10,7 @@ export async function captureComputerWindow(window) {return { image: source.thumbnail.toPNG(), size };}export function createComputerPreview() {- let host, panel, current;+ let host, panel, current, placedSession;const channel = "omnirush-computer-use-preview-action";const action = (_event, value) => {if (!panel || _event.sender !== panel.webContents || _event.senderFrame !== panel.webContents.mainFrame || !["stop", "hide", "pause"].includes(value) || !current) return;@@ -18,9 +18,30 @@ export function createComputerPreview() {else void host.action({ connectionId: current.connectionId, id: current.id, action: value }).catch(() => {});};ipcMain.on(channel, action);+ const placement = () => {+ const nativeBounds = current.windowBounds;+ const bounds = process.platform === "win32" ? screen.screenToDipRect(null, nativeBounds) : nativeBounds;+ const display = screen.getDisplayMatching(bounds), area = display.workArea;+ const box = process.platform === "linux" && display.scaleFactor !== 1+ ? Object.fromEntries(Object.entries(bounds).map(([key, value]) => [key, Math.round(value / display.scaleFactor)]))+ : bounds;+ const width = Math.min(330, area.width), height = Math.min(300, area.height), gap = 12;+ const clamp = (value, start, span, size) => Math.round(Math.max(start, Math.min(value, start + span - size)));+ const y = clamp(box.y, area.y, area.height, height), x = clamp(box.x, area.x, area.width, width);+ const candidates = [+ { x: box.x + box.width + gap, y },+ { x: box.x - width - gap, y },+ { x, y: box.y + box.height + gap },+ { x, y: box.y - height - gap },+ ];+ const position = candidates.find((p) => p.x >= area.x && p.y >= area.y && p.x + width <= area.x + area.width && p.y + height <= area.y + area.height)+ ?? { x: area.x + area.width - width, y: area.y };+ return { ...position, width, height };+ };const show = () => {- if (panel && !panel.isDestroyed()) { panel.showInactive(); return; }- panel = new BrowserWindow({ width: 330, height: 300, title: "OmniRush.ai · Computer Use", show: false, alwaysOnTop: true, resizable: true, minimizable: false, webPreferences: { preload: fileURLToPath(new URL("./computer-use-preview-preload.cjs", import.meta.url)), nodeIntegration: false, contextIsolation: true, sandbox: true, backgroundThrottling: false } });+ if (panel && !panel.isDestroyed()) { if (placedSession !== current.id) { panel.setBounds(placement()); placedSession = current.id; } panel.showInactive(); return; }+ panel = new BrowserWindow({ ...placement(), title: "OmniRush.ai · Computer Use", show: false, alwaysOnTop: true, resizable: true, minimizable: false, webPreferences: { preload: fileURLToPath(new URL("./computer-use-preview-preload.cjs", import.meta.url)), nodeIntegration: false, contextIsolation: true, sandbox: true, backgroundThrottling: false } });+ placedSession = current.id;panel.webContents.setWindowOpenHandler(() => ({ action: "deny" }));panel.webContents.on("will-navigate", (event) => event.preventDefault());panel.on("close", (event) => { if (!current) return; event.preventDefault(); void host.action({ connectionId: current.connectionId, id: current.id, action: "hide" }).catch(() => {}); });diff --git a/evals/packages/hosts/src/local.ts b/evals/packages/hosts/src/local.tsindex a8e54f29..bada7ee0 100644--- a/evals/packages/hosts/src/local.ts+++ b/evals/packages/hosts/src/local.ts@@ -641,6 +641,19 @@ export function resolveChromeBinary(env: NodeJS.ProcessEnv = process.env, platfoexport async function killLocalPid(pid: number, options: KillLocalPidOptions = {}): Promise<boolean> {if (!Number.isInteger(pid) || pid <= 0) return false;const rootWasAlive = pidIsAlive(pid);+ if (process.platform === "win32") {+ // Node cannot send console Ctrl-C to a detached Windows pnpm tree.+ // Stop this host-owned tree, including Electron and its database workers.+ if (!rootWasAlive) return false;+ await new Promise<void>((resolveKill, reject) => {+ execFile("taskkill", ["/PID", String(pid), "/T", "/F"], { encoding: "utf8", timeout: 10_000 }, (error, _stdout, stderr) => {+ if (error && pidIsAlive(pid)) { reject(new Error("Could not stop owned Windows process tree " + pid + ": " + (stderr || error.message))); return; }+ resolveKill();+ });+ });+ await waitUntilGone(pid, KILL_GRACE_MS);+ return true;+ }const graceMs = options.graceMs ?? KILL_GRACE_MS;const sentGroup = signalProcessGroup(pid, "SIGINT");const sentDirect = !sentGroup && rootWasAlive ? signalPid(pid, "SIGINT") : false;diff --git a/evals/specs/computer-use-portable-window.e2e.test.ts b/evals/specs/computer-use-portable-window.e2e.test.tsindex 447724aa..7b75d709 100644--- a/evals/specs/computer-use-portable-window.e2e.test.ts+++ b/evals/specs/computer-use-portable-window.e2e.test.ts@@ -194,14 +194,17 @@ test("Computer Use setup and approval work from the main app on Windows and Linuexpect(result).toMatchObject({ ok: true, window_title: "Workspace window", mode: "control" });return result.session_id;});- await step("The main app can stop access without relying on the agent", async () => {+ await step("Stop stays available in the main app when the preview is hidden", async () => {expect(toolState(await client.call("computer_observe", { session_id: session })).ok).toBe(true);await evalIn(app, async () => {const states = await window.__OMNIRUSH_ELECTRON__.invokeDesktop("getComputerUseState");if (!Array.isArray(states) || !states[0]) throw new Error("No active desktop session");- await window.__OMNIRUSH_ELECTRON__.invokeDesktop("computerUseAction", { connectionId: states[0].connectionId, id: states[0].id, action: "stop" });+ await window.__OMNIRUSH_ELECTRON__.invokeDesktop("computerUseAction", { connectionId: states[0].connectionId, id: states[0].id, action: "hide" });}, { awaitPromise: true });- expect(toolState(await client.call("computer_session_status", { session_id: session })).code).toBe("session_unavailable");+ expect(toolState(await client.call("computer_session_status", { session_id: session }))).toMatchObject({ state: "active", panel_visible: false });+ await waitFor(app, () => Boolean([...document.querySelectorAll('aside[aria-label="Computer Use controls"] button')].find((button) => button.textContent.trim() === "Stop")));+ await evalIn(app, () => [...document.querySelectorAll('aside[aria-label="Computer Use controls"] button')].find((button) => button.textContent.trim() === "Stop")?.click());+ await expect.poll(async () => toolState(await client.call("computer_session_status", { session_id: session })).code).toBe("session_unavailable");expect(await world.state()).toEqual([{ count: 0, draft: "Initial draft" }, { count: 0, draft: "Initial draft" }]);});});diff --git a/evals/worlds/computer-use.ts b/evals/worlds/computer-use.tsindex 0d26bcbe..1effb90a 100644--- a/evals/worlds/computer-use.ts+++ b/evals/worlds/computer-use.ts@@ -150,7 +150,7 @@ export async function computerUseWorld(_seed: Seed, { place }: { place: Place })const fixture = pipeClient(fixtureExecutable, []);const helper = pipeClient(executable, ["mcp"]);const peer = pipeClient(executable, ["mcp"]);- const close = async () => { await Promise.all([helper.close(), peer.close(), fixture.close()]); await rm(directory, { recursive: true, force: true }); };+ const close = async () => { await Promise.all([helper.close(), peer.close(), fixture.close()]); await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); };try {await fixture.request("state");const fixturePermissions = await fixture.request("permissions");@@ -317,7 +317,7 @@ export async function portableComputerUseWorld(_seed: Seed, { place }: { place:const directory = await mkdtemp(join(tmpdir(), "omnirush-native-journey-"));const launchFlags = process.platform === "linux" ? ["--no-sandbox"] : [];const fixture = await nativeFixtureClient(executable, [...launchFlags, join(root, "evals/packages/labs/fixtures/portable-computer-use-app.mjs"), join(directory, "fixture")]);- const controller = await nativeFixtureClient(executable, [...launchFlags, join(root, "evals/packages/labs/fixtures/portable-computer-use-host.mjs"), join(directory, "host")]).catch(async (error) => { await fixture.close(); await rm(directory, { recursive: true, force: true }); throw error; });+ const controller = await nativeFixtureClient(executable, [...launchFlags, join(root, "evals/packages/labs/fixtures/portable-computer-use-host.mjs"), join(directory, "host")]).catch(async (error) => { await fixture.close(); await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); throw error; });let client: ReturnType<typeof pipeClient> | undefined;let peer: ReturnType<typeof pipeClient> | undefined;try {@@ -396,10 +396,10 @@ export async function portableComputerUseWorld(_seed: Seed, { place }: { place:return { x: ((contentBounds.x + x) * bounds[0].scale - native.x) * image.width / native.width, y: ((contentBounds.y + y) * bounds[0].scale - native.y) * image.height / native.height };},async closeClient() { await main.close(); },- async [Symbol.asyncDispose]() { await Promise.all([main.close(), other.close(), controller.close(), fixture.close()]); await rm(directory, { recursive: true, force: true }); },+ async [Symbol.asyncDispose]() { await Promise.all([main.close(), other.close(), controller.close(), fixture.close()]); await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); },};} catch (error) {await Promise.all([client?.close(), peer?.close(), controller.close(), fixture.close()]);- await rm(directory, { recursive: true, force: true }); throw error;+ await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 }); throw error;}}